home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1992-10-11 | 22.5 KB | [ TEXT/KAHL]
open in: MacOS 8.1
extracted
|
Win98
extracted
|
DOS
extracted
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary ).
You can browse this item here: pentominos.c
Confidence Program Detection Match Type Support
66%
dexvert
Compact Compressed (Unix) (archive/compact)
ext
Supported
10%
dexvert
MacBinary (archive/macBinary)
fallback
Supported
1%
dexvert
Text File (text/txt)
fallback
Supported
100%
file
MacBinary II, Sun Oct 11 15:54:36 1992, modified Sun Oct 11 15:54:36 1992, creator Think C, type ASCII, 22168 bytes "pentominos.c" , at 0x5718 612 bytes resource
default (weak)
99%
file
data
default
74%
TrID
Macintosh plain text (MacBinary)
default
25%
TrID
MacBinary 2
default (weak)
100%
siegfried
fmt/1762 MacBinary (II)
default
100%
lsar
MacBinary
default
id metadata key value macFileType [ TEXT] macFileCreator [ KAHL]
hex view +--------+-------------------------+-------------------------+--------+--------+ |00000000| 00 0c 70 65 6e 74 6f 6d | 69 6e 6f 73 2e 63 00 00 |..pentom|inos.c..| |00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000040| 00 54 45 58 54 4b 41 48 | 4c 00 00 00 00 00 00 00 |.TEXTKAH|L.......| |00000050| 00 00 00 00 00 56 98 00 | 00 02 64 a6 fe 36 fc a6 |.....V..|..d..6..| |00000060| fe 36 fc 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.6......|........| |00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 01 e7 00 00 |........|........| |00000080| 2f 2a 20 54 68 69 73 20 | 66 69 6c 65 20 64 65 6d |/* This |file dem| |00000090| 6f 6e 73 74 72 61 74 65 | 73 20 68 6f 77 20 41 70 |onstrate|s how Ap| |000000a0| 70 6c 69 63 61 74 69 6f | 6e 49 64 6c 65 20 63 61 |plicatio|nIdle ca| |000000b0| 6e 20 62 65 20 75 73 65 | 64 20 74 6f 20 64 72 69 |n be use|d to dri| |000000c0| 76 65 2c 0d 20 20 20 61 | 20 63 6f 6d 70 6c 69 63 |ve,. a| complic| |000000d0| 61 74 65 64 20 63 6f 6d | 70 75 74 61 74 69 6f 6e |ated com|putation| |000000e0| 20 69 6e 20 61 6e 20 61 | 70 70 6c 69 63 61 74 69 | in an a|pplicati| |000000f0| 6f 6e 20 77 72 69 74 74 | 65 6e 20 66 72 6f 6d 20 |on writt|en from | |00000100| 4d 61 63 53 74 61 72 74 | 65 72 2e 20 0d 20 20 20 |MacStart|er. . | |00000110| 54 6f 20 75 73 65 20 74 | 68 69 73 20 66 69 6c 65 |To use t|his file| |00000120| 2c 20 79 6f 75 20 73 68 | 6f 75 6c 64 20 61 64 64 |, you sh|ould add| |00000130| 20 69 74 20 74 6f 20 74 | 68 65 20 4d 61 63 53 74 | it to t|he MacSt| |00000140| 61 72 74 65 72 2e b9 20 | 70 72 6f 6a 65 63 74 0d |arter.. |project.| |00000150| 20 20 20 61 6e 64 20 64 | 65 6c 65 74 65 20 74 68 | and d|elete th| |00000160| 65 20 63 75 72 72 65 6e | 74 20 61 70 70 6c 69 63 |e curren|t applic| |00000170| 61 74 69 6f 6e 50 72 6f | 63 73 20 66 69 6c 65 2e |ationPro|cs file.| |00000180| 0d 20 20 20 20 20 20 20 | 54 68 65 20 70 72 6f 62 |. |The prob| |00000190| 6c 65 6d 20 69 6e 20 74 | 68 69 73 20 63 61 73 65 |lem in t|his case| |000001a0| 20 69 73 20 74 68 65 20 | 73 6f 6c 75 74 69 6f 6e | is the |solution| |000001b0| 20 6f 66 20 22 70 65 6e | 74 6f 6d 69 6e 6f 20 70 | of "pen|tomino p| |000001c0| 75 7a 7a 6c 65 73 2e 22 | 0d 20 20 20 41 20 70 65 |uzzles."|. A pe| |000001d0| 6e 74 6f 6d 69 6e 6f 20 | 69 73 20 61 20 74 69 6c |ntomino |is a til| |000001e0| 65 20 63 6f 6e 73 69 73 | 74 69 6e 67 20 6f 66 20 |e consis|ting of | |000001f0| 35 20 63 6f 6e 6e 65 63 | 74 65 64 20 73 71 75 61 |5 connec|ted squa| |00000200| 72 65 73 2e 20 20 54 68 | 65 72 65 20 61 72 65 0d |res. Th|ere are.| |00000210| 20 20 20 65 78 61 63 74 | 6c 79 20 31 32 20 64 69 | exact|ly 12 di| |00000220| 66 66 65 72 65 6e 74 20 | 70 6f 73 73 69 6c 62 65 |fferent |possilbe| |00000230| 20 70 65 6e 74 6f 6d 69 | 6e 6f 73 2e 20 20 54 68 | pentomi|nos. Th| |00000240| 65 20 70 75 7a 7a 6c 65 | 73 20 69 6e 76 6f 6c 76 |e puzzle|s involv| |00000250| 65 0d 20 20 20 70 6c 61 | 63 69 6e 67 20 6f 6e 65 |e. pla|cing one| |00000260| 20 6f 66 20 65 61 63 68 | 20 74 79 70 65 20 6f 66 | of each| type of| |00000270| 20 70 65 6e 74 6f 6d 69 | 6e 6f 20 6f 6e 20 61 6e | pentomi|no on an| |00000280| 20 38 2d 62 79 2d 38 20 | 62 6f 61 72 64 2e 20 20 | 8-by-8 |board. | |00000290| 54 68 69 73 20 77 69 6c | 6c 0d 20 20 20 6c 65 61 |This wil|l. lea| |000002a0| 76 65 20 66 6f 75 72 20 | 62 6c 61 6e 6b 20 73 70 |ve four |blank sp| |000002b0| 61 63 65 73 2e 20 20 49 | 6e 20 74 68 69 73 20 70 |aces. I|n this p| |000002c0| 72 6f 67 72 61 6d 2c 20 | 74 68 65 20 73 70 61 63 |rogram, |the spac| |000002d0| 65 73 20 74 68 61 74 20 | 61 72 65 20 74 6f 0d 20 |es that |are to. | |000002e0| 20 20 62 65 20 6c 65 66 | 74 20 62 6c 61 6e 6b 20 | be lef|t blank | |000002f0| 61 72 65 20 73 70 65 63 | 69 66 69 65 64 20 69 6e |are spec|ified in| |00000300| 20 61 64 76 61 6e 63 65 | 2e 20 20 54 68 65 20 62 | advance|. The b| |00000310| 61 73 69 63 20 61 6c 67 | 6f 72 69 74 68 6d 20 75 |asic alg|orithm u| |00000320| 73 65 64 0d 20 20 20 69 | 73 20 61 20 73 69 6d 70 |sed. i|s a simp| |00000330| 6c 65 20 72 65 63 75 72 | 73 69 76 65 20 64 65 70 |le recur|sive dep| |00000340| 74 68 2d 66 69 72 73 74 | 20 73 65 61 72 63 68 3a |th-first| search:| |00000350| 20 20 54 72 79 20 74 6f | 20 70 6c 61 63 65 20 61 | Try to| place a| |00000360| 20 70 69 65 63 65 20 61 | 74 0d 20 20 20 74 68 65 | piece a|t. the| |00000370| 20 66 69 72 73 74 20 65 | 6d 70 74 79 20 73 71 75 | first e|mpty squ| |00000380| 61 72 65 3b 20 69 66 20 | 69 74 20 66 69 74 73 2c |are; if |it fits,| |00000390| 20 67 6f 20 6f 6e 20 74 | 6f 20 74 68 65 20 6e 65 | go on t|o the ne| |000003a0| 78 74 20 65 6d 70 74 79 | 20 73 70 61 63 65 0d 20 |xt empty| space. | |000003b0| 20 20 61 6e 64 20 72 65 | 70 65 61 74 3b 20 69 66 | and re|peat; if| |000003c0| 20 74 68 65 20 70 75 7a | 7a 6c 65 20 69 73 6e 27 | the puz|zle isn'| |000003d0| 74 20 73 6f 6c 76 65 64 | 20 66 61 69 6c 73 2c 20 |t solved| fails, | |000003e0| 74 72 79 20 74 68 65 20 | 6e 65 78 74 20 70 69 65 |try the |next pie| |000003f0| 63 65 3b 0d 20 20 20 69 | 66 20 74 68 65 72 65 20 |ce;. i|f there | |00000400| 69 73 20 6e 6f 20 6f 74 | 68 65 72 20 70 69 65 63 |is no ot|her piec| |00000410| 65 20 74 6f 20 74 72 79 | 2c 20 74 68 65 6e 20 74 |e to try|, then t| |00000420| 68 65 72 65 20 69 73 20 | 6e 6f 20 73 6f 6c 75 74 |here is |no solut| |00000430| 69 6f 6e 2e 0d 20 20 20 | 55 6e 66 6f 72 74 75 6e |ion.. |Unfortun| |00000440| 61 74 65 6c 79 2c 20 49 | 20 63 61 6e 27 74 20 72 |ately, I| can't r| |00000450| 65 61 6c 6c 79 20 75 73 | 65 20 61 20 73 69 6e 67 |eally us|e a sing| |00000460| 6c 65 20 72 65 63 75 72 | 73 69 76 65 20 66 75 6e |le recur|sive fun| |00000470| 63 74 69 6f 6e 0d 20 20 | 20 62 65 63 61 75 73 65 |ction. | because| |00000480| 20 49 20 61 6d 20 69 6e | 73 69 73 74 69 6e 67 20 | I am in|sisting | |00000490| 74 68 61 74 20 65 61 63 | 68 20 63 61 6c 6c 20 74 |that eac|h call t| |000004a0| 6f 20 41 70 70 6c 69 63 | 61 74 69 6f 6e 49 64 6c |o Applic|ationIdl| |000004b0| 65 20 6f 6e 6c 79 0d 20 | 20 20 64 6f 20 61 20 70 |e only. | do a p| |000004c0| 61 72 74 20 6f 66 20 74 | 68 65 20 70 72 6f 62 6c |art of t|he probl| |000004d0| 65 6d 2e 20 20 54 68 65 | 72 65 20 69 73 20 61 6c |em. The|re is al| |000004e0| 73 6f 20 61 6e 20 69 6e | 74 65 72 65 73 74 69 6e |so an in|terestin| |000004f0| 67 20 70 72 6f 62 6c 65 | 6d 20 0d 20 20 20 6f 66 |g proble|m . of| |00000500| 20 64 61 74 61 20 72 65 | 70 72 65 73 65 6e 74 61 | data re|presenta| |00000510| 74 69 6f 6e 2c 20 77 68 | 69 63 68 20 69 73 20 63 |tion, wh|ich is c| |00000520| 6f 6d 6d 65 6e 74 65 64 | 20 6f 6e 20 62 65 6c 6f |ommented| on belo| |00000530| 77 20 65 76 65 6e 20 74 | 68 6f 75 67 68 20 69 74 |w even t|hough it| |00000540| 0d 20 20 20 68 61 73 20 | 6e 6f 74 68 69 6e 67 20 |. has |nothing | |00000550| 74 6f 20 64 6f 20 77 69 | 74 68 20 4d 61 63 53 74 |to do wi|th MacSt| |00000560| 61 72 74 65 72 2e 0d 20 | 20 20 20 20 20 20 54 68 |arter.. | Th| |00000570| 69 73 20 70 72 6f 67 72 | 61 6d 20 63 61 6e 20 62 |is progr|am can b| |00000580| 65 20 73 65 74 20 74 6f | 20 63 6f 6e 74 69 6e 75 |e set to| continu| |00000590| 65 20 72 75 6e 6e 69 6e | 67 20 69 6e 20 74 68 65 |e runnin|g in the| |000005a0| 20 62 61 63 6b 67 72 6f | 75 6e 64 0d 20 20 20 75 | backgro|und. u| |000005b0| 6e 64 65 72 20 73 79 73 | 74 65 6d 20 37 20 6f 72 |nder sys|tem 7 or| |000005c0| 20 6d 75 6c 74 69 66 69 | 6e 64 65 72 2e 20 20 42 | multifi|nder. B| |000005d0| 65 66 6f 72 65 20 62 75 | 69 6c 64 69 6e 67 20 74 |efore bu|ilding t| |000005e0| 68 65 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 2c 0d |he appli|cation,.| |000005f0| 20 20 20 67 6f 20 74 6f | 20 74 68 65 20 53 65 74 | go to| the Set| |00000600| 20 50 72 6f 6a 65 63 74 | 20 54 79 70 65 20 63 6f | Project| Type co| |00000610| 6d 6d 61 6e 64 20 69 6e | 20 74 68 65 20 50 72 6f |mmand in| the Pro| |00000620| 6a 65 63 74 20 6d 65 6e | 75 2e 20 20 54 68 65 72 |ject men|u. Ther| |00000630| 65 20 69 73 0d 20 20 20 | 61 20 73 6d 61 6c 6c 20 |e is. |a small | |00000640| 69 63 6f 6e 20 6c 61 62 | 65 6c 65 64 20 22 53 49 |icon lab|eled "SI| |00000650| 5a 45 20 66 6c 61 67 73 | 22 2e 20 20 54 68 69 73 |ZE flags|". This| |00000660| 20 77 69 6c 6c 20 74 75 | 72 6e 20 69 6e 74 6f 20 | will tu|rn into | |00000670| 61 20 70 6f 70 2d 75 70 | 0d 20 20 20 6d 65 6e 75 |a pop-up|. menu| |00000680| 20 69 66 20 79 6f 75 20 | 63 6c 69 63 6b 20 6f 6e | if you |click on| |00000690| 20 69 74 2e 20 20 53 69 | 6d 70 6c 79 20 63 68 6f | it. Si|mply cho| |000006a0| 6f 73 65 20 74 68 65 20 | 63 6f 6d 6d 61 6e 64 20 |ose the |command | |000006b0| 22 42 61 63 6b 67 72 6f | 75 6e 64 0d 20 20 20 4e |"Backgro|und. N| |000006c0| 75 6c 6c 20 45 76 65 6e | 74 73 22 20 66 72 6f 6d |ull Even|ts" from| |000006d0| 20 74 68 69 73 20 6d 65 | 6e 75 2e 20 20 54 68 65 | this me|nu. The| |000006e0| 6e 2c 20 41 70 70 6c 69 | 63 61 74 69 6f 6e 49 64 |n, Appli|cationId| |000006f0| 6c 65 20 77 69 6c 6c 20 | 63 6f 6e 74 69 6e 75 65 |le will |continue| |00000700| 0d 20 20 20 74 6f 20 62 | 65 20 63 61 6c 6c 65 64 |. to b|e called| |00000710| 20 65 76 65 6e 20 77 68 | 65 6e 20 74 68 65 20 61 | even wh|en the a| |00000720| 70 70 6c 69 63 61 74 69 | 6f 6e 20 69 73 20 69 6e |pplicati|on is in| |00000730| 20 74 68 65 20 62 61 63 | 6b 67 72 6f 75 6e 64 2e | the bac|kground.| |00000740| 0d 20 20 20 20 20 20 20 | 41 6c 6c 20 70 6c 61 63 |. |All plac| |00000750| 65 73 20 77 68 65 72 65 | 20 74 68 69 73 20 66 69 |es where| this fi| |00000760| 6c 65 20 68 61 73 20 62 | 65 65 6e 20 6d 6f 64 69 |le has b|een modi| |00000770| 66 69 65 64 20 28 66 72 | 6f 6d 20 74 68 65 20 0d |fied (fr|om the .| |00000780| 20 20 20 6f 72 69 67 69 | 6e 61 6c 20 61 70 70 6c | origi|nal appl| |00000790| 69 63 61 74 69 6f 6e 50 | 72 6f 63 73 2e 63 29 20 |icationP|rocs.c) | |000007a0| 61 72 65 20 63 6f 6d 6d | 65 6e 74 65 64 20 77 69 |are comm|ented wi| |000007b0| 74 68 20 63 6f 6d 6d 65 | 6e 74 73 0d 20 20 20 74 |th comme|nts. t| |000007c0| 68 61 74 20 62 65 67 69 | 6e 20 77 69 74 68 20 2f |hat begi|n with /| |000007d0| 2f 0d 2a 2f 0d 0d 0d 23 | 69 6e 63 6c 75 64 65 20 |/.*/...#|include | |000007e0| 22 67 6c 6f 62 61 6c 73 | 2d 4d 61 63 53 74 61 72 |"globals|-MacStar| |000007f0| 74 65 72 2e 68 22 0d 0d | 6c 6f 6e 67 20 67 45 76 |ter.h"..|long gEv| |00000800| 65 6e 74 57 61 69 74 54 | 69 6d 65 20 3d 20 30 3b |entWaitT|ime = 0;| |00000810| 20 20 2f 2f 20 43 68 61 | 6e 67 65 64 20 66 72 6f | // Cha|nged fro| |00000820| 6d 20 31 30 30 30 30 30 | 20 74 6f 20 30 20 73 6f |m 100000| to 0 so| |00000830| 20 74 68 61 74 20 74 68 | 65 0d 20 20 20 20 20 20 | that th|e. | |00000840| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000850| 20 20 20 20 2f 2f 20 66 | 75 6e 63 74 69 6f 6e 20 | // f|unction | |00000860| 41 70 70 6c 69 63 61 74 | 69 6f 6e 49 64 6c 65 20 |Applicat|ionIdle | |00000870| 77 69 6c 6c 20 62 65 20 | 63 61 6c 6c 65 64 0d 20 |will be |called. | |00000880| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000890| 20 20 20 20 20 20 20 20 | 20 2f 2f 20 61 73 20 6f | | // as o| |000008a0| 66 74 65 6e 20 61 73 20 | 70 6f 73 73 69 62 6c 65 |ften as |possible| |000008b0| 2e 0d 0d 4d 65 6e 75 48 | 61 6e 64 6c 65 20 65 64 |...MenuH|andle ed| |000008c0| 69 74 4d 65 6e 75 2c 20 | 66 69 6c 65 4d 65 6e 75 |itMenu, |fileMenu| |000008d0| 3b 0d 0d 76 6f 69 64 20 | 49 6e 69 74 41 70 70 6c |;..void |InitAppl| |000008e0| 69 63 61 74 69 6f 6e 28 | 76 6f 69 64 29 3b 0d 76 |ication(|void);.v| |000008f0| 6f 69 64 20 55 70 64 61 | 74 65 4d 65 6e 75 73 28 |oid Upda|teMenus(| |00000900| 76 6f 69 64 29 3b 0d 76 | 6f 69 64 20 44 6f 45 64 |void);.v|oid DoEd| |00000910| 69 74 4d 65 6e 75 28 69 | 6e 74 20 69 74 65 6d 4e |itMenu(i|nt itemN| |00000920| 75 6d 29 3b 0d 76 6f 69 | 64 20 44 6f 46 69 6c 65 |um);.voi|d DoFile| |00000930| 4d 65 6e 75 28 69 6e 74 | 20 69 74 65 6d 4e 75 6d |Menu(int| itemNum| |00000940| 2c 20 69 6e 74 2a 20 64 | 6f 6e 65 29 3b 0d 76 6f |, int* d|one);.vo| |00000950| 69 64 20 44 6f 4f 74 68 | 65 72 4d 65 6e 75 28 69 |id DoOth|erMenu(i| |00000960| 6e 74 20 6d 65 6e 75 49 | 44 2c 20 69 6e 74 20 69 |nt menuI|D, int i| |00000970| 74 65 6d 4e 75 6d 29 3b | 0d 76 6f 69 64 20 41 70 |temNum);|.void Ap| |00000980| 70 6c 69 63 61 74 69 6f | 6e 49 64 6c 65 28 76 6f |plicatio|nIdle(vo| |00000990| 69 64 29 3b 0d 76 6f 69 | 64 20 43 6c 65 61 6e 55 |id);.voi|d CleanU| |000009a0| 70 41 70 70 6c 69 63 61 | 74 69 6f 6e 28 76 6f 69 |pApplica|tion(voi| |000009b0| 64 29 3b 0d 76 6f 69 64 | 20 41 62 6f 75 74 42 6f |d);.void| AboutBo| |000009c0| 78 28 76 6f 69 64 29 3b | 0d 76 6f 69 64 20 44 6f |x(void);|.void Do| |000009d0| 4e 65 77 43 6f 6d 6d 61 | 6e 64 28 76 6f 69 64 29 |NewComma|nd(void)| |000009e0| 3b 0d 0d 63 6f 6e 73 74 | 20 73 68 6f 72 74 20 73 |;..const| short s| |000009f0| 71 75 61 72 65 53 69 7a | 65 20 3d 20 32 31 3b 20 |quareSiz|e = 21; | |00000a00| 20 2f 2f 20 54 68 69 73 | 20 69 73 20 74 68 65 20 | // This| is the | |00000a10| 73 69 7a 65 20 6f 66 20 | 65 61 63 68 20 73 71 75 |size of |each squ| |00000a20| 61 72 65 20 69 6e 20 74 | 68 65 0d 20 20 20 20 20 |are in t|he. | |00000a30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000a40| 20 20 20 20 20 20 20 20 | 20 2f 2f 20 38 2d 62 79 | | // 8-by| |00000a50| 2d 38 20 70 6c 61 79 69 | 6e 67 20 62 6f 61 72 64 |-8 playi|ng board| |00000a60| 2e 20 20 49 74 20 63 61 | 6e 20 62 65 0d 20 20 20 |. It ca|n be. | |00000a70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000a80| 20 20 20 20 20 20 20 20 | 20 20 20 2f 2f 20 61 64 | | // ad| |00000a90| 6a 75 73 74 65 64 20 73 | 6c 69 67 68 74 6c 79 20 |justed s|lightly | |00000aa0| 74 6f 20 6d 61 6b 65 20 | 6c 61 72 67 65 72 20 6f |to make |larger o| |00000ab0| 72 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |r. | | |00000ac0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000ad0| 2f 2f 20 73 6d 61 6c 6c | 65 72 20 62 6f 61 72 64 |// small|er board| |00000ae0| 73 2e 0d 0d 73 68 6f 72 | 74 20 57 69 6e 64 6f 77 |s...shor|t Window| |00000af0| 43 74 20 3d 20 30 3b 20 | 20 2f 2f 20 54 68 69 73 |Ct = 0; | // This| |00000b00| 20 76 61 72 69 61 62 6c | 65 20 77 69 6c 6c 20 63 | variabl|e will c| |00000b10| 6f 75 6e 74 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |ount the| number | |00000b20| 6f 66 20 77 69 6e 64 6f | 77 73 0d 20 20 20 20 20 |of windo|ws. | |00000b30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000b40| 2f 2f 20 74 68 61 74 20 | 68 61 76 65 20 62 65 65 |// that |have bee| |00000b50| 6e 20 6f 70 65 6e 65 64 | 20 73 6f 20 66 61 72 2e |n opened| so far.| |00000b60| 20 20 49 74 20 69 73 20 | 69 6e 63 72 65 6d 65 6e | It is |incremen| |00000b70| 74 65 64 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |ted. | | |00000b80| 20 20 20 20 20 20 20 20 | 20 2f 2f 20 69 6e 20 44 | | // in D| |00000b90| 6f 4e 65 77 43 6f 6d 6d | 61 6e 64 20 61 6e 64 20 |oNewComm|and and | |00000ba0| 69 73 20 75 73 65 64 20 | 69 6e 20 4f 70 65 6e 49 |is used |in OpenI| |00000bb0| 6e 52 65 63 74 20 74 6f | 0d 20 20 20 20 20 20 20 |nRect to|. | |00000bc0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 2f 2f | | //| |00000bd0| 20 70 6f 73 69 74 69 6f | 6e 20 74 68 65 20 77 69 | positio|n the wi| |00000be0| 6e 64 6f 77 2e 0d 0d 74 | 79 70 65 64 65 66 20 73 |ndow...t|ypedef s| |00000bf0| 68 6f 72 74 20 62 6f 61 | 72 64 44 61 74 61 5b 31 |hort boa|rdData[1| |00000c00| 30 30 5d 3b 20 20 2f 2f | 20 54 68 65 20 38 2d 62 |00]; //| The 8-b| |00000c10| 79 2d 38 20 62 6f 61 72 | 64 20 69 73 20 61 63 74 |y-8 boar|d is act| |00000c20| 75 61 6c 6c 79 0d 20 20 | 20 20 20 20 20 20 20 20 |ually. | | |00000c30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000c40| 20 20 20 20 20 2f 2f 20 | 72 65 70 72 65 73 65 6e | // |represen| |00000c50| 74 65 64 20 62 79 20 61 | 20 31 30 2d 62 79 2d 31 |ted by a| 10-by-1| |00000c60| 30 20 64 61 74 61 20 73 | 74 72 75 63 74 75 72 65 |0 data s|tructure| |00000c70| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | | |00000c80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000c90| 2f 2f 20 69 6e 20 77 68 | 69 63 68 20 74 68 65 20 |// in wh|ich the | |00000ca0| 63 65 6c 6c 73 20 61 6c | 6f 6e 67 20 74 68 65 20 |cells al|ong the | |00000cb0| 62 6f 72 64 65 72 0d 20 | 20 20 20 20 20 20 20 20 |border. | | |00000cc0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000cd0| 20 20 20 20 20 20 2f 2f | 20 61 72 65 20 64 65 63 | //| are dec| |00000ce0| 6c 61 72 65 64 20 70 65 | 72 6d 61 6e 65 6e 74 6c |lared pe|rmanentl| |00000cf0| 79 20 22 66 69 6c 6c 65 | 64 22 0d 20 20 20 20 20 |y "fille|d". | |00000d00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000d10| 20 20 20 20 20 20 20 20 | 20 20 2f 2f 20 54 68 69 | | // Thi| |00000d20| 73 20 73 69 6d 70 6c 69 | 66 69 65 73 20 74 65 73 |s simpli|fies tes| |00000d30| 74 69 6e 67 20 77 68 65 | 74 68 65 72 20 61 20 67 |ting whe|ther a g| |00000d40| 69 76 65 6e 0d 20 20 20 | 20 20 20 20 20 20 20 20 |iven. | | |00000d50| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000d60| 20 20 20 20 2f 2f 20 70 | 69 65 63 65 20 66 69 74 | // p|iece fit| |00000d70| 73 20 61 74 20 61 20 67 | 69 76 65 6e 20 70 6f 73 |s at a g|iven pos| |00000d80| 69 74 69 6f 6e 20 6f 6e | 20 74 68 65 20 0d 20 20 |ition on| the . | |00000d90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000da0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 2f 2f 20 | | // | |00000db0| 62 6f 61 72 64 2e 20 20 | 46 75 72 74 68 65 72 6d |board. |Furtherm| |00000dc0| 6f 72 65 2c 20 74 68 69 | 73 20 31 30 2d 62 79 2d |ore, thi|s 10-by-| |00000dd0| 31 30 20 62 6f 61 72 64 | 0d 20 20 20 20 20 20 20 |10 board|. | |00000de0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000df0| 20 20 20 20 20 20 20 20 | 2f 2f 20 69 73 20 72 65 | |// is re| |00000e00| 70 72 65 73 65 6e 74 65 | 64 20 62 79 20 61 20 31 |presente|d by a 1| |00000e10| 2d 64 69 6d 65 6e 73 69 | 6f 6e 61 6c 20 61 72 72 |-dimensi|onal arr| |00000e20| 61 79 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |ay. | | |00000e30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000e40| 20 20 2f 2f 20 69 6e 20 | 77 68 69 63 68 20 74 68 | // in |which th| |00000e50| 65 20 31 30 2a 69 2b 6a | 2d 74 68 20 65 6e 74 72 |e 10*i+j|-th entr| |00000e60| 79 20 72 65 70 72 65 73 | 65 6e 74 73 0d 20 20 20 |y repres|ents. | |00000e70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00000e80| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2f 20 72 | | // r| |00000e90| 6f 77 20 6a 20 61 6e 64 | 20 63 6f 6c 75 6d 6e 20 |ow j and| column | |00000ea0| 69 20 6f 6e 20 74 68 65 | 20 62 6f 61 72 64 2e 0d |i on the| board..| |00000eb0| 0d 63 6f 6e 73 74 20 70 | 69 65 63 65 73 5b 36 33 |.const p|ieces[63| |00000ec0| 5d 5b 35 5d 20 3d 20 7b | 0d 20 20 20 7b 20 31 2c |][5] = {|. { 1,| |00000ed0| 20 31 2c 32 2c 33 2c 34 | 20 7d 2c 20 20 20 20 20 | 1,2,3,4| }, | |00000ee0| 20 20 20 20 2f 2f 20 54 | 68 69 73 20 61 72 72 61 | // T|his arra| |00000ef0| 79 20 72 65 70 72 65 73 | 65 6e 74 73 20 65 76 65 |y repres|ents eve| |00000f00| 72 79 74 68 69 6e 67 20 | 74 68 65 20 70 72 6f 67 |rything |the prog| |00000f10| 72 61 6d 0d 20 20 20 7b | 20 31 2c 20 31 30 2c 32 |ram. {| 1, 10,2| |00000f20| 30 2c 33 30 2c 34 30 20 | 7d 2c 20 20 20 20 20 2f |0,30,40 |}, /| |00000f30| 2f 20 6b 6e 6f 77 73 20 | 61 62 6f 75 74 20 74 68 |/ knows |about th| |00000f40| 65 20 69 6e 64 69 76 69 | 64 75 61 6c 20 70 65 6e |e indivi|dual pen| |00000f50| 74 6f 6d 69 6e 6f 73 2e | 20 20 45 61 63 68 0d 20 |tominos.| Each. | |00000f60| 20 20 7b 20 32 2c 20 39 | 2c 31 30 2c 31 31 2c 32 | { 2, 9|,10,11,2| |00000f70| 30 20 7d 2c 20 20 20 20 | 20 20 2f 2f 20 72 6f 77 |0 }, | // row| |00000f80| 20 69 6e 20 74 68 65 20 | 61 72 72 61 79 20 72 65 | in the |array re| |00000f90| 70 72 65 73 65 6e 74 73 | 20 61 20 70 61 72 74 69 |presents| a parti| |00000fa0| 63 75 6c 61 72 0d 20 20 | 20 7b 20 33 2c 20 31 2c |cular. | { 3, 1,| |00000fb0| 31 30 2c 31 39 2c 32 30 | 20 7d 2c 20 20 20 20 20 |10,19,20| }, | |00000fc0| 20 2f 2f 20 70 65 6e 74 | 6f 6d 69 6e 6f 20 69 6e | // pent|omino in| |00000fd0| 20 61 20 70 61 72 74 69 | 63 75 6c 61 72 20 6f 72 | a parti|cular or| |00000fe0| 69 65 6e 74 61 74 69 6f | 6e 2e 20 20 44 69 66 66 |ientatio|n. Diff| |00000ff0| 65 72 65 6e 74 0d 20 20 | 20 7b 20 33 2c 20 31 30 |erent. | { 3, 10| |00001000| 2c 31 31 2c 31 32 2c 32 | 32 20 7d 2c 20 20 20 20 |,11,12,2|2 }, | |00001010| 20 2f 2f 20 6f 72 69 65 | 6e 74 61 74 69 6f 6e 73 | // orie|ntations| |00001020| 20 61 72 65 20 6f 62 74 | 61 69 6e 65 64 20 62 79 | are obt|ained by| |00001030| 20 72 6f 74 61 74 69 6e | 67 20 6f 72 20 66 6c 69 | rotatin|g or fli| |00001040| 70 70 69 6e 67 0d 20 20 | 20 7b 20 33 2c 20 31 2c |pping. | { 3, 1,| |00001050| 31 31 2c 32 31 2c 32 32 | 20 7d 2c 20 20 20 20 20 |11,21,22| }, | |00001060| 20 2f 2f 20 74 68 65 20 | 70 65 6e 74 6f 6d 69 6e | // the |pentomin| |00001070| 6f 20 6f 76 65 72 2e 20 | 20 4e 6f 74 65 20 74 68 |o over. | Note th| |00001080| 61 74 20 74 68 65 20 70 | 72 6f 67 72 61 6d 20 6d |at the p|rogram m| |00001090| 75 73 74 0d 20 20 20 7b | 20 33 2c 20 38 2c 39 2c |ust. {| 3, 8,9,| |000010a0| 31 30 2c 31 38 20 7d 2c | 20 20 20 20 20 20 20 2f |10,18 },| /| |000010b0| 2f 20 74 72 79 20 65 61 | 63 68 20 70 65 6e 74 6f |/ try ea|ch pento| |000010c0| 6d 69 6e 6f 20 69 6e 20 | 65 61 63 68 20 70 6f 73 |mino in |each pos| |000010d0| 73 69 62 6c 65 20 6f 72 | 69 65 6e 74 61 74 69 6f |sible or|ientatio| |000010e0| 6e 2c 0d 20 20 20 7b 20 | 34 2c 20 31 30 2c 32 30 |n,. { |4, 10,20| |000010f0| 2c 32 31 2c 32 32 20 7d | 2c 20 20 20 20 20 2f 2f |,21,22 }|, //| |00001100| 20 62 75 74 20 6d 75 73 | 74 20 62 65 20 63 61 72 | but mus|t be car| |00001110| 65 66 75 6c 20 6e 6f 74 | 20 74 6f 20 72 65 75 73 |eful not| to reus| |00001120| 65 20 61 20 70 69 65 63 | 65 20 69 66 0d 20 20 20 |e a piec|e if. | |00001130| 7b 20 34 2c 20 31 2c 32 | 2c 31 30 2c 32 30 20 7d |{ 4, 1,2|,10,20 }| |00001140| 2c 20 20 20 20 20 20 20 | 2f 2f 20 69 74 20 68 61 |, |// it ha| |00001150| 73 20 61 6c 72 65 61 64 | 79 20 62 65 65 6e 20 75 |s alread|y been u| |00001160| 73 65 64 20 6f 6e 20 74 | 68 65 20 62 6f 61 72 64 |sed on t|he board| |00001170| 20 69 6e 20 61 0d 20 20 | 20 7b 20 34 2c 20 31 30 | in a. | { 4, 10| |00001180| 2c 31 38 2c 31 39 2c 32 | 30 20 7d 2c 20 20 20 20 |,18,19,2|0 }, | |00001190| 20 2f 2f 20 64 69 66 66 | 65 72 65 6e 74 20 6f 72 | // diff|erent or| |000011a0| 69 65 6e 74 61 74 69 6f | 6e 2e 0d 20 20 20 7b 20 |ientatio|n.. { | |000011b0| 34 2c 20 31 2c 32 2c 31 | 32 2c 32 32 20 7d 2c 20 |4, 1,2,1|2,22 }, | |000011c0| 20 20 20 20 20 20 2f 2f | 20 20 20 20 20 54 68 65 | //| The| |000011d0| 20 70 65 6e 74 6f 6d 69 | 6e 6f 65 73 20 61 72 65 | pentomi|noes are| |000011e0| 20 6e 75 6d 62 65 72 65 | 64 20 66 72 6f 6d 20 31 | numbere|d from 1| |000011f0| 20 74 6f 20 31 32 2e 0d | 20 20 20 7b 20 35 2c 20 | to 12..| { 5, | |00001200| 31 2c 32 2c 31 31 2c 32 | 31 20 7d 2c 20 20 20 20 |1,2,11,2|1 }, | |00001210| 20 20 20 2f 2f 20 54 68 | 65 20 66 69 72 73 74 20 | // Th|e first | |00001220| 6e 75 6d 62 65 72 20 6f | 6e 20 65 61 63 68 20 72 |number o|n each r| |00001230| 6f 77 20 74 65 6c 6c 73 | 20 77 68 69 63 68 20 70 |ow tells| which p| |00001240| 65 6e 74 6f 6d 69 6e 6f | 0d 20 20 20 7b 20 35 2c |entomino|. { 5,| |00001250| 20 38 2c 39 2c 31 30 2c | 32 30 20 7d 2c 20 20 20 | 8,9,10,|20 }, | |00001260| 20 20 20 20 2f 2f 20 74 | 68 61 74 20 72 6f 77 20 | // t|hat row | |00001270| 72 65 70 72 65 73 65 6e | 74 73 2e 20 20 4e 6f 74 |represen|ts. Not| |00001280| 65 20 74 68 61 74 20 74 | 68 65 72 65 20 63 61 6e |e that t|here can| |00001290| 20 62 65 0d 20 20 20 7b | 20 35 2c 20 31 30 2c 31 | be. {| 5, 10,1| |000012a0| 39 2c 32 30 2c 32 31 20 | 7d 2c 20 20 20 20 20 2f |9,20,21 |}, /| |000012b0| 2f 20 75 70 20 74 6f 20 | 38 20 64 69 66 66 65 72 |/ up to |8 differ| |000012c0| 65 6e 74 20 72 6f 77 73 | 20 66 6f 72 20 65 61 63 |ent rows| for eac| |000012d0| 68 20 70 65 6e 74 6f 6d | 69 6e 6f 2e 0d 20 20 20 |h pentom|ino.. | |000012e0| 7b 20 35 2c 20 31 30 2c | 31 31 2c 31 32 2c 32 30 |{ 5, 10,|11,12,20| |000012f0| 20 7d 2c 20 20 20 20 20 | 2f 2f 20 73 6f 6d 65 20 | }, |// some | |00001300| 70 65 6e 74 6f 6d 69 6e | 6f 73 20 68 61 76 65 20 |pentomin|os have | |00001310| 66 65 77 65 72 20 72 6f | 77 73 20 62 65 63 61 75 |fewer ro|ws becau| |00001320| 73 65 20 74 68 65 79 20 | 61 72 65 0d 20 20 20 7b |se they |are. {| |00001330| 20 36 2c 20 31 30 2c 31 | 31 2c 32 31 2c 32 32 20 | 6, 10,1|1,21,22 | |00001340| 7d 2c 20 20 20 20 20 2f | 2f 20 73 79 6d 6d 65 74 |}, /|/ symmet| |00001350| 72 69 63 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |ric. Fo|r exampl| |00001360| 65 2c 20 74 68 65 20 70 | 65 6e 74 6f 6d 69 6e 6f |e, the p|entomino| |00001370| 20 74 68 61 74 20 6c 6f | 6f 6b 73 0d 20 20 20 7b | that lo|oks. {| |00001380| 20 36 2c 20 39 2c 31 30 | 2c 31 38 2c 31 39 20 7d | 6, 9,10|,18,19 }| |00001390| 2c 20 20 20 20 20 20 2f | 2f 20 6c 69 6b 65 3a 0d |, /|/ like:.| |000013a0| 20 20 20 7b 20 36 2c 20 | 31 2c 31 31 2c 31 32 2c | { 6, |1,11,12,| |000013b0| 32 32 20 7d 2c 20 20 20 | 20 20 20 2f 2f 20 20 20 |22 }, | // | |000013c0| 20 20 20 20 20 20 20 20 | 47 47 47 0d 20 20 20 7b | |GGG. {| |000013d0| 20 36 2c 20 31 2c 39 2c | 31 30 2c 31 39 20 7d 2c | 6, 1,9,|10,19 },| |000013e0| 20 20 20 20 20 20 20 2f | 2f 20 20 20 20 20 20 20 | /|/ | |000013f0| 20 20 20 20 47 20 47 0d | 20 20 20 7b 20 37 2c 20 | G G.| { 7, | |00001400| 31 2c 32 2c 31 30 2c 31 | 32 20 7d 2c 20 20 20 20 |1,2,10,1|2 }, | |00001410| 20 20 20 2f 2f 0d 20 20 | 20 7b 20 37 2c 20 31 2c | //. | { 7, 1,| |00001420| 31 31 2c 32 30 2c 32 31 | 20 7d 2c 20 20 20 20 20 |11,20,21| }, | |00001430| 20 2f 2f 20 63 61 6e 20 | 62 65 20 72 6f 74 61 74 | // can |be rotat| |00001440| 65 64 20 69 6e 74 6f 20 | 74 68 72 65 65 20 61 64 |ed into |three ad| |00001450| 64 69 74 69 6f 6e 61 6c | 20 70 6f 73 69 74 69 6f |ditional| positio| |00001460| 6e 73 2c 0d 20 20 20 7b | 20 37 2c 20 32 2c 31 30 |ns,. {| 7, 2,10| |00001470| 2c 31 31 2c 31 32 20 7d | 2c 20 20 20 20 20 20 2f |,11,12 }|, /| |00001480| 2f 20 62 75 74 20 66 6c | 69 70 70 69 6e 67 20 69 |/ but fl|ipping i| |00001490| 74 20 6f 76 65 72 20 77 | 69 6c 6c 20 67 69 76 65 |t over w|ill give| |000014a0| 20 6e 6f 74 68 69 6e 67 | 20 6e 65 77 2e 0d 20 20 | nothing| new.. | |000014b0| 20 7b 20 37 2c 20 31 2c | 31 30 2c 32 30 2c 32 31 | { 7, 1,|10,20,21| |000014c0| 20 7d 2c 20 20 20 20 20 | 20 2f 2f 20 53 6f 2c 20 | }, | // So, | |000014d0| 69 74 20 68 61 73 20 6f | 6e 6c 79 20 34 20 65 6e |it has o|nly 4 en| |000014e0| 74 72 69 65 73 20 69 6e | 20 74 68 65 20 61 72 72 |tries in| the arr| |000014f0| 61 79 2e 0d 20 20 20 7b | 20 38 2c 20 31 30 2c 31 |ay.. {| 8, 10,1| |00001500| 31 2c 31 32 2c 31 33 20 | 7d 2c 20 20 20 20 20 2f |1,12,13 |}, /| |00001510| 2f 20 20 20 20 20 54 68 | 65 20 66 6f 75 72 20 72 |/ Th|e four r| |00001520| 65 6d 61 69 6e 69 6e 67 | 20 65 6e 74 72 69 65 73 |emaining| entries| |00001530| 20 69 6e 20 74 68 65 20 | 61 72 72 61 79 0d 20 20 | in the |array. | |00001540| 20 7b 20 38 2c 20 31 30 | 2c 32 30 2c 32 39 2c 33 | { 8, 10|,20,29,3| |00001550| 30 20 7d 2c 20 20 20 20 | 20 2f 2f 20 64 65 73 63 |0 }, | // desc| |00001560| 72 69 62 65 20 74 68 65 | 20 67 69 76 65 6e 20 70 |ribe the| given p| |00001570| 69 65 63 65 20 69 6e 20 | 74 68 65 20 67 69 76 65 |iece in |the give| |00001580| 6e 20 6f 72 69 65 6e 74 | 61 74 69 6f 6e 2c 0d 20 |n orient|ation,. | |00001590| 20 20 7b 20 38 2c 20 31 | 2c 32 2c 33 2c 31 33 20 | { 8, 1|,2,3,13 | |000015a0| 7d 2c 20 20 20 20 20 20 | 20 20 2f 2f 20 69 6e 20 |}, | // in | |000015b0| 61 20 77 61 79 20 63 6f | 6e 76 65 6e 69 65 6e 74 |a way co|nvenient| |000015c0| 20 66 6f 72 20 70 6c 61 | 63 69 6e 67 20 74 68 65 | for pla|cing the| |000015d0| 20 70 69 65 63 65 20 69 | 6e 74 6f 0d 20 20 20 7b | piece i|nto. {| |000015e0| 20 38 2c 20 31 2c 31 30 | 2c 32 30 2c 33 30 20 7d | 8, 1,10|,20,30 }| |000015f0| 2c 20 20 20 20 20 20 2f | 2f 20 74 68 65 20 6f 6e |, /|/ the on| |00001600| 65 2d 64 69 6d 65 6e 73 | 69 6f 6e 61 6c 20 61 72 |e-dimens|ional ar| |00001610| 72 61 79 20 74 68 61 74 | 20 72 65 70 72 65 73 65 |ray that| represe| |00001620| 6e 74 73 20 74 68 65 0d | 20 20 20 7b 20 38 2c 20 |nts the.| { 8, | |00001630| 31 2c 31 31 2c 32 31 2c | 33 31 20 7d 2c 20 20 20 |1,11,21,|31 }, | |00001640| 20 20 20 2f 2f 20 62 6f | 61 72 64 2e 20 20 41 73 | // bo|ard. As| |00001650| 20 61 6e 20 65 78 61 6d | 70 6c 65 2c 20 63 6f 6e | an exam|ple, con| |00001660| 73 69 64 65 72 20 74 68 | 65 20 72 6f 77 0d 20 20 |sider th|e row. | |00001670| 20 7b 20 38 2c 20 31 2c | 32 2c 33 2c 31 30 20 7d | { 8, 1,|2,3,10 }| |00001680| 2c 20 20 20 20 20 20 20 | 20 2f 2f 0d 20 20 20 7b |, | //. {| |00001690| 20 38 2c 20 31 30 2c 32 | 30 2c 33 30 2c 33 31 20 | 8, 10,2|0,30,31 | |000016a0| 7d 2c 20 20 20 20 20 2f | 2f 20 20 20 20 20 20 20 |}, /|/ | |000016b0| 20 20 20 20 7b 20 37 2c | 20 31 2c 32 2c 31 30 2c | { 7,| 1,2,10,| |000016c0| 31 39 20 7d 0d 20 20 20 | 7b 20 38 2c 20 37 2c 38 |19 }. |{ 8, 7,8| |000016d0| 2c 39 2c 31 30 20 7d 2c | 20 20 20 20 20 20 20 20 |,9,10 },| | |000016e0| 2f 2f 0d 20 20 20 7b 20 | 39 2c 20 31 2c 38 2c 39 |//. { |9, 1,8,9| |000016f0| 2c 31 30 20 7d 2c 20 20 | 20 20 20 20 20 20 2f 2f |,10 }, | //| |00001700| 20 49 66 20 74 68 69 73 | 20 70 69 65 63 65 20 69 | If this| piece i| |00001710| 73 20 70 6c 61 63 65 64 | 20 6f 6e 20 74 68 65 20 |s placed| on the | |00001720| 62 6f 61 72 64 20 73 6f | 20 74 68 61 74 0d 20 20 |board so| that. | |00001730| 20 7b 20 39 2c 20 31 30 | 2c 31 31 2c 32 31 2c 33 | { 9, 10|,11,21,3| |00001740| 31 20 7d 2c 20 20 20 20 | 20 2f 2f 20 69 74 73 20 |1 }, | // its | |00001750| 74 6f 70 6d 6f 73 74 2f | 6c 65 66 74 6d 6f 73 74 |topmost/|leftmost| |00001760| 20 73 71 75 61 72 65 20 | 66 69 6c 6c 73 20 70 6f | square |fills po| |00001770| 73 69 74 69 6f 6e 0d 20 | 20 20 7b 20 39 2c 20 31 |sition. | { 9, 1| |00001780| 2c 32 2c 39 2c 31 30 20 | 7d 2c 20 20 20 20 20 20 |,2,9,10 |}, | |00001790| 20 20 2f 2f 20 70 20 69 | 6e 20 74 68 65 20 61 72 | // p i|n the ar| |000017a0| 72 61 79 2c 20 74 68 65 | 6e 20 74 68 65 20 6f 74 |ray, the|n the ot| |000017b0| 68 65 72 20 66 6f 75 72 | 20 73 71 75 61 72 65 73 |her four| squares| |000017c0| 0d 20 20 20 7b 20 39 2c | 20 31 30 2c 32 30 2c 32 |. { 9,| 10,20,2| |000017d0| 31 2c 33 31 20 7d 2c 20 | 20 20 20 20 2f 2f 20 77 |1,31 }, | // w| |000017e0| 69 6c 6c 20 62 65 20 61 | 74 20 70 6f 73 69 74 69 |ill be a|t positi| |000017f0| 6f 6e 73 20 20 70 2b 31 | 2c 20 70 2b 32 2c 20 70 |ons p+1|, p+2, p| |00001800| 2b 31 30 2c 20 61 6e 64 | 20 70 2b 31 39 2e 0d 20 |+10, and| p+19.. | |00001810| 20 20 7b 20 39 2c 20 31 | 2c 31 31 2c 31 32 2c 31 | { 9, 1|,11,12,1| |00001820| 33 20 7d 2c 20 20 20 20 | 20 20 2f 2f 20 54 6f 20 |3 }, | // To | |00001830| 73 65 65 20 77 68 65 74 | 68 65 72 20 74 68 65 20 |see whet|her the | |00001840| 70 69 65 63 65 20 63 61 | 6e 20 62 65 20 70 6c 61 |piece ca|n be pla| |00001850| 79 65 64 20 61 74 20 74 | 68 61 74 0d 20 20 20 7b |yed at t|hat. {| |00001860| 20 39 2c 20 31 30 2c 31 | 39 2c 32 30 2c 32 39 20 | 9, 10,1|9,20,29 | |00001870| 7d 2c 20 20 20 20 20 2f | 2f 20 70 6f 73 69 74 69 |}, /|/ positi| |00001880| 6f 6e 2c 20 69 74 20 73 | 75 66 66 69 63 65 73 20 |on, it s|uffices | |00001890| 74 6f 20 63 68 65 63 6b | 20 77 68 65 74 68 65 72 |to check| whether| |000018a0| 20 61 6e 79 20 6f 66 0d | 20 20 20 7b 20 39 2c 20 | any of.| { 9, | |000018b0| 31 2c 32 2c 31 32 2c 31 | 33 20 7d 2c 20 20 20 20 |1,2,12,1|3 }, | |000018c0| 20 20 20 2f 2f 20 74 68 | 65 73 65 20 66 69 76 65 | // th|ese five| |000018d0| 20 73 71 75 61 72 65 73 | 20 61 72 65 20 66 69 6c | squares| are fil| |000018e0| 6c 65 64 2e 20 20 49 66 | 20 74 68 65 20 70 69 65 |led. If| the pie| |000018f0| 63 65 20 69 73 0d 20 20 | 20 7b 20 39 2c 20 39 2c |ce is. | { 9, 9,| |00001900| 31 30 2c 31 39 2c 32 39 | 20 7d 2c 20 20 20 20 20 |10,19,29| }, | |00001910| 20 2f 2f 20 70 6c 61 79 | 65 64 2c 20 74 68 6f 73 | // play|ed, thos| |00001920| 65 20 66 69 76 65 20 70 | 6c 61 63 65 73 20 69 6e |e five p|laces in| |00001930| 20 74 68 65 20 61 72 72 | 61 79 20 61 72 65 20 66 | the arr|ay are f| |00001940| 69 6c 6c 65 64 0d 20 20 | 20 7b 20 31 30 2c 20 38 |illed. | { 10, 8| |00001950| 2c 39 2c 31 30 2c 31 31 | 20 7d 2c 20 20 20 20 20 |,9,10,11| }, | |00001960| 20 2f 2f 20 77 69 74 68 | 20 61 20 6c 65 74 74 65 | // with| a lette| |00001970| 72 20 72 65 70 72 65 73 | 65 6e 74 69 6e 67 20 74 |r repres|enting t| |00001980| 68 65 20 70 65 6e 74 6f | 6d 69 6e 6f 20 28 27 41 |he pento|mino ('A| |00001990| 27 20 66 6f 72 0d 20 20 | 20 7b 20 31 30 2c 20 39 |' for. | { 10, 9| |000019a0| 2c 31 30 2c 32 30 2c 33 | 30 20 7d 2c 20 20 20 20 |,10,20,3|0 }, | |000019b0| 20 2f 2f 20 70 65 6e 74 | 6f 6d 69 6e 6f 20 31 2c | // pent|omino 1,| |000019c0| 20 27 42 27 20 66 6f 72 | 20 70 65 6e 74 6f 6d 69 | 'B' for| pentomi| |000019d0| 6e 6f 20 32 2c 20 65 74 | 63 2e 29 0d 20 20 20 7b |no 2, et|c.). {| |000019e0| 20 31 30 2c 20 31 2c 32 | 2c 33 2c 31 31 20 7d 2c | 10, 1,2|,3,11 },| |000019f0| 0d 20 20 20 7b 20 31 30 | 2c 20 31 30 2c 32 30 2c |. { 10|, 10,20,| |00001a00| 32 31 2c 33 30 20 7d 2c | 0d 20 20 20 7b 20 31 30 |21,30 },|. { 10| |00001a10| 2c 20 31 2c 32 2c 33 2c | 31 32 20 7d 2c 0d 20 20 |, 1,2,3,|12 },. | |00001a20| 20 7b 20 31 30 2c 20 31 | 30 2c 31 31 2c 32 30 2c | { 10, 1|0,11,20,| |00001a30| 33 30 20 7d 2c 0d 20 20 | 20 7b 20 31 30 2c 20 39 |30 },. | { 10, 9| |00001a40| 2c 31 30 2c 31 31 2c 31 | 32 20 7d 2c 0d 20 20 20 |,10,11,1|2 },. | |00001a50| 7b 20 31 30 2c 20 31 30 | 2c 31 39 2c 32 30 2c 33 |{ 10, 10|,19,20,3| |00001a60| 30 20 7d 2c 0d 20 20 20 | 7b 20 31 31 2c 20 39 2c |0 },. |{ 11, 9,| |00001a70| 31 30 2c 31 31 2c 32 31 | 20 7d 2c 0d 20 20 20 7b |10,11,21| },. {| |00001a80| 20 31 31 2c 20 31 2c 39 | 2c 31 30 2c 32 30 20 7d | 11, 1,9|,10,20 }| |00001a90| 2c 0d 20 20 20 7b 20 31 | 31 2c 20 31 30 2c 31 31 |,. { 1|1, 10,11| |00001aa0| 2c 31 32 2c 32 31 20 7d | 2c 0d 20 20 20 7b 20 31 |,12,21 }|,. { 1| |00001ab0| 31 2c 20 31 30 2c 31 31 | 2c 31 39 2c 32 30 20 7d |1, 10,11|,19,20 }| |00001ac0| 2c 0d 20 20 20 7b 20 31 | 31 2c 20 38 2c 39 2c 31 |,. { 1|1, 8,9,1| |00001ad0| 30 2c 31 39 7d 2c 0d 20 | 20 20 7b 20 31 31 2c 20 |0,19},. | { 11, | |00001ae0| 31 2c 31 31 2c 31 32 2c | 32 31 20 7d 2c 0d 20 20 |1,11,12,|21 },. | |00001af0| 20 7b 20 31 31 2c 20 39 | 2c 31 30 2c 31 31 2c 31 | { 11, 9|,10,11,1| |00001b00| 39 20 7d 2c 0d 20 20 20 | 7b 20 31 31 2c 20 39 2c |9 },. |{ 11, 9,| |00001b10| 31 30 2c 32 30 2c 32 31 | 20 7d 2c 0d 20 20 20 7b |10,20,21| },. {| |00001b20| 20 31 32 2c 20 31 2c 31 | 30 2c 31 31 2c 32 31 20 | 12, 1,1|0,11,21 | |00001b30| 7d 2c 0d 20 20 20 7b 20 | 31 32 2c 20 31 2c 32 2c |},. { |12, 1,2,| |00001b40| 31 30 2c 31 31 20 7d 2c | 0d 20 20 20 7b 20 31 32 |10,11 },|. { 12| |00001b50| 2c 20 31 30 2c 31 31 2c | 32 30 2c 32 31 20 7d 2c |, 10,11,|20,21 },| |00001b60| 0d 20 20 20 7b 20 31 32 | 2c 20 31 2c 39 2c 31 30 |. { 12|, 1,9,10| |00001b70| 2c 31 31 20 7d 2c 0d 20 | 20 20 7b 20 31 32 2c 20 |,11 },. | { 12, | |00001b80| 31 2c 31 30 2c 31 31 2c | 31 32 20 7d 2c 0d 20 20 |1,10,11,|12 },. | |00001b90| 20 7b 20 31 32 2c 20 39 | 2c 31 30 2c 31 39 2c 32 | { 12, 9|,10,19,2| |00001ba0| 30 20 7d 2c 0d 20 20 20 | 7b 20 31 32 2c 20 31 2c |0 },. |{ 12, 1,| |00001bb0| 32 2c 31 31 2c 31 32 20 | 7d 2c 0d 20 20 20 7b 20 |2,11,12 |},. { | |00001bc0| 31 32 2c 20 31 2c 31 30 | 2c 31 31 2c 32 30 20 7d |12, 1,10|,11,20 }| |00001bd0| 2c 20 0d 20 7d 3b 0d 0d | 74 79 70 65 64 65 66 20 |, . };..|typedef | |00001be0| 65 6e 75 6d 20 7b 20 20 | 20 2f 2f 20 54 68 69 73 |enum { | // This| |00001bf0| 20 74 79 70 65 20 69 73 | 20 61 20 63 6f 6e 76 65 | type is| a conve| |00001c00| 6e 69 65 6e 63 74 20 66 | 6f 72 20 6b 65 65 70 69 |nienct f|or keepi| |00001c10| 6e 67 20 74 72 61 63 6b | 20 61 20 62 6f 61 72 64 |ng track| a board| |00001c20| 27 73 20 73 74 61 74 75 | 73 2e 0d 20 20 20 73 65 |'s statu|s.. se| |00001c30| 74 74 69 6e 67 55 70 2c | 20 20 2f 2f 20 3d 20 54 |ttingUp,| // = T| |00001c40| 68 65 20 75 73 65 72 20 | 68 61 73 20 6e 6f 74 20 |he user |has not | |00001c50| 79 65 74 20 63 68 6f 73 | 65 6e 20 74 68 65 20 66 |yet chos|en the f| |00001c60| 6f 75 72 20 65 6d 70 74 | 79 20 73 70 61 63 65 73 |our empt|y spaces| |00001c70| 2e 0d 20 20 20 72 75 6e | 6e 69 6e 67 2c 20 20 20 |.. run|ning, | |00001c80| 20 2f 2f 20 3d 20 54 68 | 65 20 70 72 6f 67 72 61 | // = Th|e progra| |00001c90| 6d 20 69 73 20 6c 6f 6f | 6b 69 6e 67 20 66 6f 72 |m is loo|king for| |00001ca0| 20 61 20 73 6f 6c 75 74 | 69 6f 6e 2e 0d 20 20 20 | a solut|ion.. | |00001cb0| 66 69 6e 69 73 68 65 64 | 2c 20 20 20 2f 2f 20 3d |finished|, // =| |00001cc0| 20 41 20 73 6f 6c 75 74 | 69 6f 6e 20 68 61 73 20 | A solut|ion has | |00001cd0| 62 65 65 6e 20 66 6f 75 | 6e 64 20 61 6e 64 20 69 |been fou|nd and i| |00001ce0| 73 20 62 65 69 6e 67 20 | 64 69 73 70 6c 61 79 65 |s being |displaye| |00001cf0| 64 0d 20 20 20 6e 6f 53 | 6f 6c 75 74 69 6f 6e 20 |d. noS|olution | |00001d00| 20 2f 2f 20 3d 20 41 66 | 74 65 72 20 74 72 79 69 | // = Af|ter tryi| |00001d10| 6e 67 20 61 6c 6c 20 70 | 6f 73 73 69 62 69 6c 69 |ng all p|ossibili| |00001d20| 74 69 65 73 2c 20 6e 6f | 20 73 6f 6c 75 74 69 6f |ties, no| solutio| |00001d30| 6e 20 68 61 73 20 62 65 | 65 6e 20 66 6f 75 6e 64 |n has be|en found| |00001d40| 0d 7d 20 77 69 6e 53 74 | 61 74 65 3b 0d 0d 0d 2f |.} winSt|ate;.../| |00001d50| 2f 20 44 65 63 6c 61 72 | 65 20 74 77 6f 20 66 75 |/ Declar|e two fu| |00001d60| 6e 63 74 69 6f 6e 73 20 | 66 6f 72 20 70 6c 61 63 |nctions |for plac| |00001d70| 69 6e 67 20 70 69 65 63 | 65 73 20 61 6e 64 20 72 |ing piec|es and r| |00001d80| 65 6d 6f 76 69 6e 67 20 | 70 69 65 63 65 73 20 66 |emoving |pieces f| |00001d90| 72 6f 6d 20 74 68 65 0d | 2f 2f 20 62 6f 61 72 64 |rom the.|// board| |00001da0| 2e 20 20 4e 6f 74 65 20 | 74 68 61 74 20 74 68 65 |. Note |that the| |00001db0| 73 65 20 66 75 6e 63 74 | 69 6f 6e 73 20 61 72 65 |se funct|ions are| |00001dc0| 20 72 65 73 70 6f 6e 73 | 69 62 6c 65 20 66 6f 72 | respons|ible for| |00001dd0| 20 6d 61 69 6e 74 61 69 | 6e 69 6e 67 20 62 6f 74 | maintai|ning bot| |00001de0| 68 0d 2f 2f 20 74 68 65 | 20 73 63 72 65 65 6e 20 |h.// the| screen | |00001df0| 61 6e 64 20 74 68 65 20 | 62 6f 61 72 64 20 64 61 |and the |board da| |00001e00| 74 61 20 73 74 72 75 63 | 74 75 72 65 2e 20 20 28 |ta struc|ture. (| |00001e10| 49 74 20 69 73 20 6e 6f | 74 20 61 20 67 6f 6f 64 |It is no|t a good| |00001e20| 20 69 64 65 61 20 74 6f | 0d 2f 2f 20 73 65 70 61 | idea to|.// sepa| |00001e30| 72 61 74 65 20 73 75 63 | 68 20 66 75 6e 63 74 69 |rate suc|h functi| |00001e40| 6f 6e 73 2e 29 20 20 54 | 68 65 73 65 20 61 72 65 |ons.) T|hese are| |00001e50| 20 62 6f 74 68 20 63 61 | 6c 6c 65 64 20 62 79 20 | both ca|lled by | |00001e60| 74 68 65 20 68 69 67 68 | 65 72 20 6c 65 76 65 6c |the high|er level| |00001e70| 0d 2f 2f 20 66 75 6e 63 | 74 69 6f 6e 20 6d 79 57 |.// func|tion myW| |00001e80| 69 6e 64 6f 77 3a 3a 70 | 6c 61 79 50 69 65 63 65 |indow::p|layPiece| |00001e90| 2e 0d 0d 73 68 6f 72 74 | 20 70 75 74 50 69 65 63 |...short| putPiec| |00001ea0| 65 28 73 68 6f 72 74 20 | 70 69 65 63 65 2c 20 73 |e(short |piece, s| |00001eb0| 68 6f 72 74 20 77 68 65 | 72 65 2c 20 62 6f 61 72 |hort whe|re, boar| |00001ec0| 64 44 61 74 61 20 62 6f | 61 72 64 29 3b 20 20 20 |dData bo|ard); | |00001ed0| 0d 73 68 6f 72 74 20 65 | 72 61 73 65 50 69 65 63 |.short e|rasePiec| |00001ee0| 65 28 73 68 6f 72 74 20 | 70 69 65 63 65 2c 20 73 |e(short |piece, s| |00001ef0| 68 6f 72 74 20 77 68 65 | 72 65 2c 20 62 6f 61 72 |hort whe|re, boar| |00001f00| 64 44 61 74 61 20 62 6f | 61 72 64 29 3b 20 0d 0d |dData bo|ard); ..| |00001f10| 2f 2f 20 46 75 6e 63 74 | 69 6f 6e 20 70 75 74 50 |// Funct|ion putP| |00001f20| 69 65 63 65 20 74 72 69 | 65 73 20 74 6f 20 70 6c |iece tri|es to pl| |00001f30| 61 63 65 20 61 20 73 70 | 65 63 69 66 65 64 20 70 |ace a sp|ecifed p| |00001f40| 69 65 63 65 20 69 6e 20 | 61 20 73 70 65 63 69 66 |iece in |a specif| |00001f50| 69 65 64 20 70 6f 73 69 | 74 69 6f 6e 0d 2f 2f 20 |ied posi|tion.// | |00001f60| 6f 6e 20 74 68 65 20 62 | 6f 61 72 64 20 62 6f 61 |on the b|oard boa| |00001f70| 72 64 44 61 74 61 2e 20 | 20 49 66 20 61 6c 6c 20 |rdData. | If all | |00001f80| 74 68 65 20 6c 6f 63 61 | 74 69 6f 6e 73 20 6e 65 |the loca|tions ne| |00001f90| 65 64 65 64 20 62 79 20 | 74 68 65 20 70 69 65 63 |eded by |the piec| |00001fa0| 65 20 61 72 65 0d 2f 2f | 20 65 6d 70 74 79 2c 20 |e are.//| empty, | |00001fb0| 74 68 65 6e 20 74 68 69 | 73 20 66 75 6e 63 74 69 |then thi|s functi| |00001fc0| 6f 6e 20 66 69 6c 6c 73 | 20 69 6e 20 74 68 6f 73 |on fills| in thos| |00001fd0| 65 20 73 70 61 63 65 73 | 20 69 6e 20 74 68 65 20 |e spaces| in the | |00001fe0| 61 72 72 61 79 20 77 69 | 74 68 20 74 68 65 0d 2f |array wi|th the./| |00001ff0| 2f 20 6e 75 6d 62 65 72 | 20 6f 66 20 74 68 65 20 |/ number| of the | |00002000| 70 65 6e 74 6f 6d 69 6e | 6f 20 61 6e 64 20 61 6c |pentomin|o and al| |00002010| 73 6f 20 64 72 61 77 73 | 20 74 68 65 20 70 69 65 |so draws| the pie| |00002020| 63 65 20 6f 6e 20 74 68 | 65 20 62 6f 61 72 64 2e |ce on th|e board.| |00002030| 0d 2f 2f 20 49 6e 20 74 | 68 69 73 20 63 61 73 65 |.// In t|his case| |00002040| 2c 20 61 20 76 61 6c 75 | 65 20 6f 66 20 31 20 69 |, a valu|e of 1 i| |00002050| 73 20 72 65 74 75 72 6e | 65 64 2e 20 20 49 66 20 |s return|ed. If | |00002060| 74 68 65 20 70 69 65 63 | 65 20 63 61 6e 6e 6f 74 |the piec|e cannot| |00002070| 20 62 65 20 70 6c 61 79 | 65 64 2c 0d 2f 2f 20 61 | be play|ed,.// a| |00002080| 20 76 61 6c 75 65 20 6f | 66 20 30 20 69 73 20 72 | value o|f 0 is r| |00002090| 65 74 75 72 6e 65 64 2e | 20 20 54 68 69 73 20 66 |eturned.| This f| |000020a0| 75 6e 63 74 69 6f 6e 20 | 61 73 73 75 6d 65 73 20 |unction |assumes | |000020b0| 74 68 61 74 20 74 68 65 | 20 64 72 61 77 69 6e 67 |that the| drawing| |000020c0| 20 70 6f 72 74 20 69 73 | 0d 2f 2f 20 73 65 74 20 | port is|.// set | |000020d0| 74 6f 20 74 68 65 20 63 | 6f 72 72 65 63 74 20 77 |to the c|orrect w| |000020e0| 69 6e 64 6f 77 2e 20 20 | 4e 6f 74 65 20 74 68 61 |indow. |Note tha| |000020f0| 74 20 74 68 65 20 70 61 | 72 61 6d 65 74 65 72 20 |t the pa|rameter | |00002100| 70 69 65 63 65 4e 75 6d | 20 69 73 20 61 6e 20 69 |pieceNum| is an i| |00002110| 6e 64 65 78 0d 2f 2f 20 | 74 6f 20 74 68 65 20 64 |ndex.// |to the d| |00002120| 61 74 61 20 66 6f 72 20 | 74 68 65 20 70 69 65 63 |ata for |the piec| |00002130| 65 20 69 6e 20 74 68 65 | 20 67 6c 6f 62 61 6c 20 |e in the| global | |00002140| 61 72 72 61 79 20 22 70 | 69 65 63 65 73 22 3b 20 |array "p|ieces"; | |00002150| 74 68 65 20 61 63 74 75 | 61 6c 20 6e 75 6d 62 65 |the actu|al numbe| |00002160| 72 20 6f 66 0d 2f 2f 20 | 74 68 65 20 70 65 6e 74 |r of.// |the pent| |00002170| 6f 6d 69 6e 6f 20 62 65 | 69 6e 67 20 70 6c 61 79 |omino be|ing play| |00002180| 65 64 20 69 73 20 74 68 | 75 73 20 70 69 65 63 65 |ed is th|us piece| |00002190| 73 5b 70 69 65 63 65 4e | 75 6d 5d 5b 30 5d 2e 0d |s[pieceN|um][0]..| |000021a0| 0d 73 68 6f 72 74 20 70 | 75 74 50 69 65 63 65 28 |.short p|utPiece(| |000021b0| 73 68 6f 72 74 20 70 69 | 65 63 65 4e 75 6d 2c 20 |short pi|eceNum, | |000021c0| 73 68 6f 72 74 20 77 68 | 65 72 65 2c 20 62 6f 61 |short wh|ere, boa| |000021d0| 72 64 44 61 74 61 20 62 | 6f 61 72 64 29 7b 0d 20 |rdData b|oard){. | |000021e0| 20 20 73 68 6f 72 74 20 | 69 2c 6a 2c 6b 2c 6c 6f | short |i,j,k,lo| |000021f0| 63 3b 0d 20 20 20 2f 2f | 20 74 65 73 74 20 69 66 |c;. //| test if| |00002200| 20 61 6e 79 20 6f 66 20 | 74 68 65 20 73 70 61 63 | any of |the spac| |00002210| 65 73 20 61 72 65 20 61 | 6c 72 65 61 64 79 20 66 |es are a|lready f| |00002220| 69 6c 6c 65 64 0d 20 20 | 20 69 66 20 28 62 6f 61 |illed. | if (boa| |00002230| 72 64 5b 77 68 65 72 65 | 5d 29 0d 20 20 20 20 20 |rd[where|]). | |00002240| 20 72 65 74 75 72 6e 20 | 30 3b 0d 20 20 20 66 6f | return |0;. fo| |00002250| 72 20 28 69 3d 31 3b 20 | 69 3c 35 3b 20 69 2b 2b |r (i=1; |i<5; i++| |00002260| 29 0d 20 20 20 20 20 20 | 69 66 20 28 62 6f 61 72 |). |if (boar| |00002270| 64 5b 20 77 68 65 72 65 | 20 2b 20 70 69 65 63 65 |d[ where| + piece| |00002280| 73 5b 70 69 65 63 65 4e | 75 6d 5d 5b 69 5d 20 5d |s[pieceN|um][i] ]| |00002290| 29 0d 20 20 20 20 20 20 | 20 20 20 72 65 74 75 72 |). | retur| |000022a0| 6e 20 30 3b 0d 20 20 20 | 2f 2f 20 69 66 20 74 68 |n 0;. |// if th| |000022b0| 65 20 70 69 65 63 65 20 | 63 61 6e 20 62 65 20 70 |e piece |can be p| |000022c0| 6c 61 79 65 64 2c 20 74 | 68 65 6e 20 64 6f 20 73 |layed, t|hen do s| |000022d0| 6f 2e 0d 20 20 20 62 6f | 61 72 64 5b 77 68 65 72 |o.. bo|ard[wher| |000022e0| 65 5d 20 3d 20 70 69 65 | 63 65 73 5b 70 69 65 63 |e] = pie|ces[piec| |000022f0| 65 4e 75 6d 5d 5b 30 5d | 20 2d 20 31 20 2b 20 27 |eNum][0]| - 1 + '| |00002300| 41 27 3b 0d 20 20 20 6b | 20 3d 20 77 68 65 72 65 |A';. k| = where| |00002310| 20 25 20 31 30 3b 0d 20 | 20 20 6a 20 3d 20 77 68 | % 10;. | j = wh| |00002320| 65 72 65 20 2f 20 31 30 | 3b 0d 20 20 20 4d 6f 76 |ere / 10|;. Mov| |00002330| 65 54 6f 28 28 6b 2d 31 | 29 2a 73 71 75 61 72 65 |eTo((k-1|)*square| |00002340| 53 69 7a 65 2b 38 2c 28 | 6a 2d 31 29 2a 73 71 75 |Size+8,(|j-1)*squ| |00002350| 61 72 65 53 69 7a 65 2b | 31 34 29 3b 0d 20 20 20 |areSize+|14);. | |00002360| 44 72 61 77 43 68 61 72 | 28 62 6f 61 72 64 5b 77 |DrawChar|(board[w| |00002370| 68 65 72 65 5d 29 3b 0d | 20 20 20 66 6f 72 20 28 |here]);.| for (| |00002380| 69 3d 31 3b 20 69 3c 35 | 3b 20 69 2b 2b 29 20 7b |i=1; i<5|; i++) {| |00002390| 0d 20 20 20 20 20 20 6c | 6f 63 20 3d 20 77 68 65 |. l|oc = whe| |000023a0| 72 65 20 2b 20 70 69 65 | 63 65 73 5b 70 69 65 63 |re + pie|ces[piec| |000023b0| 65 4e 75 6d 5d 5b 69 5d | 3b 0d 20 20 20 20 20 20 |eNum][i]|;. | |000023c0| 62 6f 61 72 64 5b 6c 6f | 63 5d 20 3d 20 70 69 65 |board[lo|c] = pie| |000023d0| 63 65 73 5b 70 69 65 63 | 65 4e 75 6d 5d 5b 30 5d |ces[piec|eNum][0]| |000023e0| 2d 31 2b 27 41 27 3b 0d | 20 20 20 20 20 20 6b 20 |-1+'A';.| k | |000023f0| 3d 20 6c 6f 63 20 25 20 | 31 30 3b 0d 20 20 20 20 |= loc % |10;. | |00002400| 20 20 6a 20 3d 20 6c 6f | 63 20 2f 20 31 30 3b 0d | j = lo|c / 10;.| |00002410| 20 20 20 20 20 20 4d 6f | 76 65 54 6f 28 28 6b 2d | Mo|veTo((k-| |00002420| 31 29 2a 73 71 75 61 72 | 65 53 69 7a 65 2b 38 2c |1)*squar|eSize+8,| |00002430| 28 6a 2d 31 29 2a 73 71 | 75 61 72 65 53 69 7a 65 |(j-1)*sq|uareSize| |00002440| 2b 31 34 29 3b 0d 20 20 | 20 20 20 20 44 72 61 77 |+14);. | Draw| |00002450| 43 68 61 72 28 62 6f 61 | 72 64 5b 6c 6f 63 5d 29 |Char(boa|rd[loc])| |00002460| 3b 0d 20 20 20 20 20 20 | 69 66 20 28 62 6f 61 72 |;. |if (boar| |00002470| 64 5b 6c 6f 63 5d 20 3d | 3d 20 27 40 27 29 20 7b |d[loc] =|= '@') {| |00002480| 0d 20 20 20 20 20 20 20 | 20 20 6b 2b 2b 3b 0d 20 |. | k++;. | |00002490| 20 20 20 20 20 7d 0d 20 | 20 20 20 7d 0d 20 20 20 | }. | }. | |000024a0| 20 72 65 74 75 72 6e 20 | 31 3b 0d 7d 0d 0d 0d 2f | return |1;.}.../| |000024b0| 2f 20 46 75 6e 63 74 69 | 6f 6e 20 65 72 61 73 65 |/ Functi|on erase| |000024c0| 50 69 65 63 65 20 69 73 | 20 63 61 6c 6c 65 64 20 |Piece is| called | |000024d0| 74 6f 20 72 65 6d 6f 76 | 65 20 61 20 70 69 65 63 |to remov|e a piec| |000024e0| 65 20 66 72 6f 6d 20 74 | 68 65 20 62 6f 61 72 64 |e from t|he board| |000024f0| 0d 2f 2f 20 61 6e 64 20 | 66 72 6f 6d 20 74 68 65 |.// and |from the| |00002500| 20 73 63 72 65 65 6e 2e | 20 20 49 74 20 69 73 20 | screen.| It is | |00002510| 61 73 73 75 6d 65 64 20 | 74 68 61 74 20 74 68 65 |assumed |that the| |00002520| 20 64 72 61 77 69 6e 67 | 20 70 6f 72 74 20 69 73 | drawing| port is| |00002530| 20 73 65 74 0d 2f 2f 20 | 74 6f 20 74 68 65 20 61 | set.// |to the a| |00002540| 70 70 72 6f 70 72 69 61 | 74 65 20 77 69 6e 64 6f |ppropria|te windo| |00002550| 77 20 77 68 65 6e 20 74 | 68 65 20 66 75 6e 63 74 |w when t|he funct| |00002560| 69 6f 6e 20 69 73 20 63 | 61 6c 6c 65 64 2e 0d 2f |ion is c|alled../| |00002570| 2f 20 49 74 20 69 73 20 | 61 6c 73 6f 20 61 73 73 |/ It is |also ass| |00002580| 75 6d 65 64 20 74 68 61 | 74 20 74 68 65 20 73 70 |umed tha|t the sp| |00002590| 65 63 69 66 69 65 64 20 | 70 69 65 63 65 20 69 73 |ecified |piece is| |000025a0| 20 61 63 74 75 61 6c 6c | 79 20 61 74 20 74 68 65 | actuall|y at the| |000025b0| 0d 2f 2f 20 73 70 65 63 | 69 66 69 65 64 20 6c 6f |.// spec|ified lo| |000025c0| 63 61 74 69 6f 6e 21 21 | 0d 0d 73 68 6f 72 74 20 |cation!!|..short | |000025d0| 65 72 61 73 65 50 69 65 | 63 65 28 73 68 6f 72 74 |erasePie|ce(short| |000025e0| 20 70 69 65 63 65 4e 75 | 6d 2c 20 73 68 6f 72 74 | pieceNu|m, short| |000025f0| 20 77 68 65 72 65 2c 20 | 62 6f 61 72 64 44 61 74 | where, |boardDat| |00002600| 61 20 62 6f 61 72 64 29 | 7b 0d 20 20 20 73 68 6f |a board)|{. sho| |00002610| 72 74 20 69 2c 6a 2c 6b | 2c 6c 6f 63 3b 0d 20 20 |rt i,j,k|,loc;. | |00002620| 20 6b 20 3d 20 77 68 65 | 72 65 20 25 20 31 30 3b | k = whe|re % 10;| |00002630| 0d 20 20 20 6a 20 3d 20 | 77 68 65 72 65 20 2f 20 |. j = |where / | |00002640| 31 30 3b 0d 20 20 20 4d | 6f 76 65 54 6f 28 28 6b |10;. M|oveTo((k| |00002650| 2d 31 29 2a 73 71 75 61 | 72 65 53 69 7a 65 2b 38 |-1)*squa|reSize+8| |00002660| 2c 28 6a 2d 31 29 2a 73 | 71 75 61 72 65 53 69 7a |,(j-1)*s|quareSiz| |00002670| 65 2b 31 34 29 3b 0d 20 | 20 20 44 72 61 77 43 68 |e+14);. | DrawCh| |00002680| 61 72 28 62 6f 61 72 64 | 5b 77 68 65 72 65 5d 29 |ar(board|[where])| |00002690| 3b 0d 20 20 20 62 6f 61 | 72 64 5b 77 68 65 72 65 |;. boa|rd[where| |000026a0| 5d 20 3d 20 30 3b 0d 20 | 20 20 66 6f 72 20 28 69 |] = 0;. | for (i| |000026b0| 3d 31 3b 20 69 3c 35 3b | 20 69 2b 2b 29 20 7b 0d |=1; i<5;| i++) {.| |000026c0| 20 20 20 20 20 20 6c 6f | 63 20 3d 20 77 68 65 72 | lo|c = wher| |000026d0| 65 20 2b 20 70 69 65 63 | 65 73 5b 70 69 65 63 65 |e + piec|es[piece| |000026e0| 4e 75 6d 5d 5b 69 5d 3b | 0d 20 20 20 20 20 20 6b |Num][i];|. k| |000026f0| 20 3d 20 6c 6f 63 20 25 | 20 31 30 3b 0d 20 20 20 | = loc %| 10;. | |00002700| 20 20 20 6a 20 3d 20 6c | 6f 63 20 2f 20 31 30 3b | j = l|oc / 10;| |00002710| 0d 20 20 20 20 20 20 4d | 6f 76 65 54 6f 28 28 6b |. M|oveTo((k| |00002720| 2d 31 29 2a 73 71 75 61 | 72 65 53 69 7a 65 2b 38 |-1)*squa|reSize+8| |00002730| 2c 28 6a 2d 31 29 2a 73 | 71 75 61 72 65 53 69 7a |,(j-1)*s|quareSiz| |00002740| 65 2b 31 34 29 3b 0d 20 | 20 20 20 20 20 44 72 61 |e+14);. | Dra| |00002750| 77 43 68 61 72 28 62 6f | 61 72 64 5b 6c 6f 63 5d |wChar(bo|ard[loc]| |00002760| 29 3b 0d 20 20 20 20 20 | 20 62 6f 61 72 64 5b 6c |);. | board[l| |00002770| 6f 63 5d 20 3d 20 30 3b | 0d 20 20 20 20 7d 3b 0d |oc] = 0;|. };.| |00002780| 20 20 20 72 65 74 75 72 | 6e 20 31 3b 0d 7d 0d 0d | retur|n 1;.}..| |00002790| 0d 0d 0d 63 6c 61 73 73 | 20 6d 79 57 69 6e 64 6f |...class| myWindo| |000027a0| 77 20 3a 20 70 75 62 6c | 69 63 20 78 57 69 6e 64 |w : publ|ic xWind| |000027b0| 6f 77 20 7b 0d 0d 20 20 | 20 2f 2f 20 44 61 74 61 |ow {.. | // Data| |000027c0| 20 6e 65 65 64 65 64 20 | 66 6f 72 20 74 68 69 73 | needed |for this| |000027d0| 20 77 69 6e 64 6f 77 3b | 20 65 61 63 68 20 77 69 | window;| each wi| |000027e0| 6e 64 6f 77 20 72 65 70 | 72 65 73 65 6e 74 73 20 |ndow rep|resents | |000027f0| 6f 6e 65 20 70 75 7a 7a | 6c 65 20 62 6f 61 72 64 |one puzz|le board| |00002800| 0d 20 20 20 0d 20 20 20 | 77 69 6e 53 74 61 74 65 |. . |winState| |00002810| 20 73 74 61 74 65 3b 20 | 20 20 20 20 20 20 2f 2f | state; | //| |00002820| 20 77 69 6e 64 6f 77 20 | 73 74 61 74 65 3b 20 74 | window |state; t| |00002830| 79 70 65 20 77 69 6e 53 | 74 61 74 65 20 69 73 20 |ype winS|tate is | |00002840| 64 65 66 69 6e 65 64 20 | 61 62 6f 76 65 0d 20 20 |defined |above. | |00002850| 20 62 6f 61 72 64 44 61 | 74 61 20 66 69 6c 6c 65 | boardDa|ta fille| |00002860| 64 3b 20 20 20 20 20 2f | 2f 20 64 61 74 61 20 66 |d; /|/ data f| |00002870| 6f 72 20 74 68 65 20 70 | 75 7a 7a 6c 65 20 62 6f |or the p|uzzle bo| |00002880| 61 72 64 20 61 73 73 6f | 63 69 61 74 65 64 20 77 |ard asso|ciated w| |00002890| 69 74 68 20 74 68 69 73 | 20 77 69 6e 64 6f 77 0d |ith this| window.| |000028a0| 20 20 20 73 68 6f 72 74 | 20 63 6c 69 63 6b 65 64 | short| clicked| |000028b0| 3b 20 20 20 20 20 20 20 | 20 2f 2f 20 68 6f 77 20 |; | // how | |000028c0| 6d 61 6e 79 20 73 71 75 | 61 72 65 73 20 68 61 73 |many squ|ares has| |000028d0| 20 74 68 65 20 75 73 65 | 72 20 63 6c 69 63 6b 65 | the use|r clicke| |000028e0| 64 20 6f 6e 3f 20 20 54 | 68 65 73 65 20 61 72 65 |d on? T|hese are| |000028f0| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | | |00002900| 20 20 20 20 20 20 20 20 | 20 20 2f 2f 20 20 20 74 | | // t| |00002910| 68 65 20 73 71 75 61 72 | 65 73 20 74 68 61 74 20 |he squar|es that | |00002920| 61 72 65 20 74 6f 20 72 | 65 6d 61 69 6e 20 65 6d |are to r|emain em| |00002930| 70 74 79 2e 20 20 57 68 | 65 6e 20 74 68 65 20 0d |pty. Wh|en the .| |00002940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002950| 20 20 20 20 20 20 20 20 | 20 2f 2f 20 20 20 75 73 | | // us| |00002960| 65 72 20 68 61 73 20 63 | 6c 69 63 6b 65 64 20 6f |er has c|licked o| |00002970| 6e 20 66 6f 75 72 20 73 | 75 63 68 20 73 71 75 61 |n four s|uch squa| |00002980| 72 65 73 2c 20 74 68 65 | 20 70 72 6f 67 72 61 6d |res, the| program| |00002990| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | | |000029a0| 20 20 20 20 20 20 20 20 | 20 20 2f 2f 20 20 20 73 | | // s| |000029b0| 74 61 72 74 73 20 73 6f | 6c 76 69 6e 67 20 74 68 |tarts so|lving th| |000029c0| 65 20 70 75 7a 7a 6c 65 | 2e 0d 20 20 20 73 68 6f |e puzzle|.. sho| |000029d0| 72 74 20 70 6c 61 79 65 | 64 3b 20 20 20 20 20 20 |rt playe|d; | |000029e0| 20 20 20 2f 2f 20 68 6f | 77 20 6d 61 6e 79 20 70 | // ho|w many p| |000029f0| 69 65 63 65 73 20 61 72 | 65 20 63 75 72 72 65 6e |ieces ar|e curren| |00002a00| 74 6c 79 20 70 6c 61 79 | 65 64 20 6f 6e 20 74 68 |tly play|ed on th| |00002a10| 65 20 62 6f 61 72 64 3f | 0d 20 20 20 73 68 6f 72 |e board?|. shor| |00002a20| 74 20 75 73 65 64 5b 31 | 33 5d 3b 20 20 20 20 20 |t used[1|3]; | |00002a30| 20 20 2f 2f 20 75 73 65 | 64 5b 70 5d 20 69 73 20 | // use|d[p] is | |00002a40| 73 65 74 20 74 6f 20 31 | 20 69 66 20 70 65 6e 74 |set to 1| if pent| |00002a50| 6f 6d 69 6e 6f 20 6e 75 | 6d 62 65 72 20 70 20 69 |omino nu|mber p i| |00002a60| 73 20 63 75 72 72 65 6e | 74 6c 79 0d 20 20 20 20 |s curren|tly. | |00002a70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002a80| 20 20 20 20 20 2f 2f 20 | 20 20 6f 6e 20 74 68 65 | // | on the| |00002a90| 20 62 6f 61 72 64 20 28 | 75 73 65 64 5b 30 5d 20 | board (|used[0] | |00002aa0| 69 73 20 6e 6f 74 20 75 | 73 65 64 29 0d 20 20 20 |is not u|sed). | |00002ab0| 73 68 6f 72 74 20 70 69 | 65 63 65 53 74 61 63 6b |short pi|eceStack| |00002ac0| 5b 31 32 5d 3b 20 2f 2f | 20 70 69 65 63 65 53 74 |[12]; //| pieceSt| |00002ad0| 61 63 6b 5b 30 5d 2c 2e | 2e 2e 2c 70 69 65 63 65 |ack[0],.|..,piece| |00002ae0| 53 74 61 63 6b 5b 70 6c | 61 79 65 64 2d 31 5d 20 |Stack[pl|ayed-1] | |00002af0| 67 69 76 65 20 74 68 65 | 0d 20 20 20 20 20 20 20 |give the|. | |00002b00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002b10| 20 20 2f 2f 20 20 20 6c | 69 73 74 20 6f 66 20 70 | // l|ist of p| |00002b20| 69 65 63 65 73 20 63 75 | 72 72 65 6e 74 6c 79 20 |ieces cu|rrently | |00002b30| 6f 6e 20 74 68 65 20 62 | 6f 61 72 64 2e 20 20 45 |on the b|oard. E| |00002b40| 61 63 68 20 65 6e 74 72 | 79 0d 20 20 20 20 20 20 |ach entr|y. | |00002b50| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002b60| 20 20 20 2f 2f 20 20 20 | 69 73 20 61 63 74 75 61 | // |is actua| |00002b70| 6c 6c 79 20 61 6e 20 69 | 6e 64 65 78 20 74 6f 20 |lly an i|ndex to | |00002b80| 74 68 65 20 67 6c 6f 62 | 61 6c 20 61 72 72 61 79 |the glob|al array| |00002b90| 20 22 70 69 65 63 65 73 | 22 2e 0d 20 20 20 20 20 | "pieces|".. | |00002ba0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002bb0| 20 20 20 20 2f 2f 20 20 | 20 49 74 20 69 73 20 70 | // | It is p| |00002bc0| 6f 73 73 69 62 6c 65 20 | 74 68 61 74 20 70 69 65 |ossible |that pie| |00002bd0| 63 65 73 5b 70 6c 61 79 | 65 64 2d 31 5d 20 69 73 |ces[play|ed-1] is| |00002be0| 20 2d 31 2c 0d 20 20 20 | 20 20 20 20 20 20 20 20 | -1,. | | |00002bf0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 2f 2f | | //| |00002c00| 20 20 20 69 6e 64 69 63 | 61 74 69 6e 67 20 74 68 | indic|ating th| |00002c10| 61 74 20 6e 6f 20 70 69 | 65 63 65 20 68 61 73 20 |at no pi|ece has | |00002c20| 79 65 74 20 62 65 65 6e | 20 74 72 69 65 64 20 6f |yet been| tried o| |00002c30| 6e 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |n. | | |00002c40| 20 20 20 20 20 20 20 20 | 20 20 20 2f 2f 20 20 20 | | // | |00002c50| 74 68 65 20 63 75 72 72 | 65 6e 74 20 74 6f 70 20 |the curr|ent top | |00002c60| 22 6c 65 76 65 6c 20 6f | 66 20 72 65 63 75 72 73 |"level o|f recurs| |00002c70| 69 6f 6e 22 2e 0d 20 20 | 20 73 68 6f 72 74 20 73 |ion".. | short s| |00002c80| 71 75 61 72 65 53 74 61 | 63 6b 5b 31 33 5d 3b 2f |quareSta|ck[13];/| |00002c90| 2f 20 73 71 75 61 72 65 | 53 74 61 63 6b 5b 30 5d |/ square|Stack[0]| |00002ca0| 2c 2e 2e 2e 2c 73 71 75 | 61 72 65 53 74 61 63 74 |,...,squ|areStact| |00002cb0| 5b 70 6c 61 79 65 64 2d | 31 5d 20 72 65 63 6f 72 |[played-|1] recor| |00002cc0| 64 20 74 68 65 0d 20 20 | 20 20 20 20 20 20 20 20 |d the. | | |00002cd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 2f | | /| |00002ce0| 2f 20 20 20 6e 65 78 74 | 20 65 6d 70 74 79 20 73 |/ next| empty s| |00002cf0| 71 75 61 72 65 20 6f 6e | 20 74 68 65 20 62 6f 61 |quare on| the boa| |00002d00| 72 64 20 61 66 74 65 72 | 20 65 61 63 68 0d 20 20 |rd after| each. | |00002d10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002d20| 20 20 20 20 20 20 20 2f | 2f 20 20 20 6f 66 20 74 | /|/ of t| |00002d30| 68 65 20 70 69 65 63 65 | 73 20 69 6e 20 70 69 65 |he piece|s in pie| |00002d40| 63 65 53 74 61 63 6b 20 | 77 61 73 20 70 6c 61 79 |ceStack |was play| |00002d50| 65 64 0d 0d 20 70 75 62 | 6c 69 63 3a 0d 20 20 20 |ed.. pub|lic:. | |00002d60| 76 6f 69 64 20 70 6c 61 | 79 50 69 65 63 65 28 76 |void pla|yPiece(v| |00002d70| 6f 69 64 29 3b 20 2f 2f | 20 74 68 69 73 20 69 73 |oid); //| this is| |00002d80| 20 61 20 6e 65 77 20 66 | 75 6e 63 74 69 6f 6e 2c | a new f|unction,| |00002d90| 20 72 65 73 70 6f 6e 73 | 69 62 6c 65 20 66 6f 72 | respons|ible for| |00002da0| 20 70 6c 61 63 69 6e 67 | 0d 20 20 20 20 20 20 20 | placing|. | |00002db0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00002dc0| 20 20 2f 2f 20 74 68 65 | 20 6e 65 78 74 20 70 69 | // the| next pi| |00002dd0| 65 63 65 20 6f 6e 20 74 | 68 65 20 62 6f 61 72 64 |ece on t|he board| |00002de0| 2e 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.. | | |00002df0| 20 20 20 20 20 20 20 20 | 20 20 20 0d 20 20 20 76 | | . v| |00002e00| 69 72 74 75 61 6c 20 76 | 6f 69 64 20 4f 70 65 6e |irtual v|oid Open| |00002e10| 49 6e 52 65 63 74 28 53 | 74 72 32 35 35 20 74 69 |InRect(S|tr255 ti| |00002e20| 74 6c 65 2c 20 69 6e 74 | 20 6c 65 66 74 2c 20 69 |tle, int| left, i| |00002e30| 6e 74 20 74 6f 70 2c 20 | 69 6e 74 20 72 69 67 68 |nt top, |int righ| |00002e40| 74 2c 20 69 6e 74 20 62 | 6f 74 74 6f 6d 29 3b 20 |t, int b|ottom); | |00002e50| 20 20 0d 20 20 20 76 69 | 72 74 75 61 6c 20 73 68 | . vi|rtual sh| |00002e60| 6f 72 74 20 43 6c 6f 73 | 65 28 76 6f 69 64 29 3b |ort Clos|e(void);| |00002e70| 0d 0d 20 70 72 6f 74 65 | 63 74 65 64 3a 0d 20 20 |.. prote|cted:. | |00002e80| 20 76 69 72 74 75 61 6c | 20 76 6f 69 64 20 53 65 | virtual| void Se| |00002e90| 74 44 65 66 61 75 6c 74 | 73 28 76 6f 69 64 29 3b |tDefault|s(void);| |00002ea0| 0d 20 20 20 76 69 72 74 | 75 61 6c 20 76 6f 69 64 |. virt|ual void| |00002eb0| 20 64 6f 4b 65 79 28 63 | 68 61 72 20 63 68 29 3b | doKey(c|har ch);| |00002ec0| 0d 20 20 20 76 69 72 74 | 75 61 6c 20 76 6f 69 64 |. virt|ual void| |00002ed0| 20 64 6f 43 6f 6e 74 65 | 6e 74 43 6c 69 63 6b 28 | doConte|ntClick(| |00002ee0| 50 6f 69 6e 74 20 6c 6f | 63 61 6c 50 74 29 3b 0d |Point lo|calPt);.| |00002ef0| 20 20 20 76 69 72 74 75 | 61 6c 20 76 6f 69 64 20 | virtu|al void | |00002f00| 61 64 6a 75 73 74 54 6f | 4e 65 77 53 69 7a 65 28 |adjustTo|NewSize(| |00002f10| 76 6f 69 64 29 3b 0d 20 | 20 20 76 69 72 74 75 61 |void);. | virtua| |00002f20| 6c 20 76 6f 69 64 20 64 | 6f 52 65 64 72 61 77 28 |l void d|oRedraw(| |00002f30| 52 65 63 74 2a 20 62 61 | 64 52 65 63 74 29 3b 0d |Rect* ba|dRect);.| |00002f40| 20 20 20 76 69 72 74 75 | 61 6c 20 76 6f 69 64 20 | virtu|al void | |00002f50| 64 6f 48 53 63 72 6f 6c | 6c 28 69 6e 74 20 64 68 |doHScrol|l(int dh| |00002f60| 29 3b 0d 20 20 20 76 69 | 72 74 75 61 6c 20 76 6f |);. vi|rtual vo| |00002f70| 69 64 20 64 6f 56 53 63 | 72 6f 6c 6c 28 69 6e 74 |id doVSc|roll(int| |00002f80| 20 64 76 29 3b 0d 20 20 | 20 76 69 72 74 75 61 6c | dv);. | virtual| |00002f90| 20 76 6f 69 64 20 64 6f | 41 63 74 69 76 61 74 65 | void do|Activate| |00002fa0| 28 69 6e 74 20 61 63 74 | 69 76 65 29 3b 0d 7d 3b |(int act|ive);.};| |00002fb0| 0d 0d 0d 0d 2f 2f 20 46 | 75 6e 63 74 69 6f 6e 20 |....// F|unction | |00002fc0| 70 6c 61 79 50 69 65 63 | 65 20 69 73 20 63 61 6c |playPiec|e is cal| |00002fd0| 6c 65 64 20 62 79 20 66 | 75 6e 63 74 69 6f 6e 20 |led by f|unction | |00002fe0| 41 70 70 6c 69 63 61 74 | 69 6f 6e 49 64 6c 65 20 |Applicat|ionIdle | |00002ff0| 74 6f 20 70 6c 61 63 65 | 20 74 68 65 0d 2f 2f 20 |to place| the.// | |00003000| 6e 65 78 74 20 70 69 65 | 63 65 20 6f 6e 20 74 68 |next pie|ce on th| |00003010| 65 20 62 6f 61 72 64 2e | 20 20 49 74 20 64 6f 65 |e board.| It doe| |00003020| 73 20 6a 75 73 74 20 6f | 6e 65 20 73 74 65 70 20 |s just o|ne step | |00003030| 69 6e 20 73 6f 6c 76 69 | 6e 67 20 74 68 65 20 70 |in solvi|ng the p| |00003040| 75 7a 7a 6c 65 2e 0d 2f | 2f 20 41 63 74 75 61 6c |uzzle../|/ Actual| |00003050| 6c 79 2c 20 74 68 69 73 | 20 66 75 6e 63 74 69 6f |ly, this| functio| |00003060| 6e 20 69 73 20 63 61 6c | 6c 65 64 20 6f 6e 6c 79 |n is cal|led only| |00003070| 20 66 6f 72 20 74 68 65 | 20 66 69 72 73 74 20 77 | for the| first w| |00003080| 69 6e 64 6f 77 20 69 6e | 20 74 68 65 0d 2f 2f 20 |indow in| the.// | |00003090| 6c 69 73 74 20 6f 66 20 | 77 69 6e 64 6f 77 73 2c |list of |windows,| |000030a0| 20 78 57 69 6e 64 6f 77 | 4c 69 73 74 2c 20 77 68 | xWindow|List, wh| |000030b0| 69 63 68 20 63 6f 6e 74 | 61 69 6e 73 20 61 6c 6c |ich cont|ains all| |000030c0| 20 74 68 65 20 77 69 6e | 64 6f 77 73 20 63 75 72 | the win|dows cur| |000030d0| 72 65 6e 74 6c 79 0d 2f | 2f 20 6f 70 65 6e 20 69 |rently./|/ open i| |000030e0| 6e 20 74 68 65 20 70 72 | 6f 67 72 61 6d 2e 20 20 |n the pr|ogram. | |000030f0| 28 78 57 69 6e 64 6f 77 | 4c 69 73 74 20 69 73 20 |(xWindow|List is | |00003100| 61 20 67 6c 6f 62 61 6c | 20 76 61 72 69 61 62 6c |a global| variabl| |00003110| 65 2e 29 20 20 54 68 65 | 20 66 75 6e 63 74 69 6f |e.) The| functio| |00003120| 6e 0d 2f 2f 20 63 61 6c | 6c 20 69 73 20 70 61 73 |n.// cal|l is pas| |00003130| 73 65 64 20 64 6f 77 6e | 20 74 68 69 73 20 6c 69 |sed down| this li| |00003140| 73 74 20 62 79 20 74 68 | 65 20 66 69 72 73 74 20 |st by th|e first | |00003150| 73 74 61 74 65 6d 65 6e | 74 20 6f 66 20 74 68 69 |statemen|t of thi| |00003160| 73 20 66 75 6e 63 74 69 | 6f 6e 2c 0d 2f 2f 20 73 |s functi|on,.// s| |00003170| 6f 20 74 68 61 74 20 65 | 61 63 68 20 77 69 6e 64 |o that e|ach wind| |00003180| 6f 77 20 67 65 74 73 20 | 61 20 63 68 61 6e 63 65 |ow gets |a chance| |00003190| 20 74 6f 20 64 6f 20 6f | 6e 65 20 73 74 65 70 20 | to do o|ne step | |000031a0| 69 6e 20 69 74 73 20 70 | 75 7a 7a 6c 65 2e 0d 2f |in its p|uzzle../| |000031b0| 2f 20 28 54 68 69 73 20 | 69 73 20 74 68 65 20 68 |/ (This |is the h| |000031c0| 65 61 72 74 20 6f 66 20 | 74 68 65 20 61 6c 67 6f |eart of |the algo| |000031d0| 72 69 74 68 6d 20 74 68 | 61 74 20 73 6f 6c 76 65 |rithm th|at solve| |000031e0| 73 20 74 68 65 20 70 65 | 6e 74 6f 6d 69 6e 6f 73 |s the pe|ntominos| |000031f0| 20 70 75 7a 7a 6c 65 2e | 0d 2f 2f 20 20 49 74 20 | puzzle.|.// It | |00003200| 69 6d 69 74 61 74 65 73 | 20 61 20 72 65 63 75 72 |imitates| a recur| |00003210| 73 69 76 65 2c 20 64 65 | 70 74 68 2d 66 69 72 73 |sive, de|pth-firs| |00003220| 74 20 73 65 61 72 63 68 | 2e 29 0d 0d 76 6f 69 64 |t search|.)..void| |00003230| 20 6d 79 57 69 6e 64 6f | 77 3a 3a 70 6c 61 79 50 | myWindo|w::playP| |00003240| 69 65 63 65 28 76 6f 69 | 64 29 20 7b 0d 20 20 20 |iece(voi|d) {. | |00003250| 73 68 6f 72 74 20 70 69 | 65 63 65 4e 75 6d 3b 0d |short pi|eceNum;.| |00003260| 20 20 20 73 68 6f 72 74 | 20 65 6d 70 74 79 53 71 | short| emptySq| |00003270| 75 61 72 65 3b 0d 20 20 | 20 69 66 20 28 6e 65 78 |uare;. | if (nex| |00003280| 74 57 69 6e 64 6f 77 29 | 20 20 2f 2f 20 70 61 73 |tWindow)| // pas| |00003290| 73 20 66 75 6e 63 74 69 | 6f 6e 20 63 61 6c 6c 20 |s functi|on call | |000032a0| 64 6f 77 6e 20 63 68 61 | 69 6e 20 6f 66 20 6f 70 |down cha|in of op| |000032b0| 65 6e 20 77 69 6e 64 6f | 77 73 2e 0d 20 20 20 20 |en windo|ws.. | |000032c0| 20 20 28 28 6d 79 57 69 | 6e 64 6f 77 2a 29 6e 65 | ((myWi|ndow*)ne| |000032d0| 78 74 57 69 6e 64 6f 77 | 29 2d 3e 70 6c 61 79 50 |xtWindow|)->playP| |000032e0| 69 65 63 65 28 29 3b 0d | 20 20 20 69 66 20 28 73 |iece();.| if (s| |000032f0| 74 61 74 65 20 21 3d 20 | 72 75 6e 6e 69 6e 67 29 |tate != |running)| |00003300| 20 20 2f 2f 20 74 68 69 | 73 20 66 75 6e 63 74 69 | // thi|s functi| |00003310| 6f 6e 20 64 6f 65 73 6e | 27 74 20 64 6f 20 61 6e |on doesn|'t do an| |00003320| 79 74 68 69 6e 67 0d 20 | 20 20 20 20 20 72 65 74 |ything. | ret| |00003330| 75 72 6e 3b 20 20 20 20 | 20 20 20 20 20 20 20 20 |urn; | | |00003340| 20 2f 2f 20 20 20 69 6e | 20 61 20 77 69 6e 64 6f | // in| a windo| |00003350| 77 20 74 68 61 74 20 69 | 73 6e 27 74 20 63 75 72 |w that i|sn't cur| |00003360| 72 65 6e 74 6c 79 20 22 | 72 75 6e 6e 69 6e 67 22 |rently "|running"| |00003370| 0d 20 20 20 53 65 74 50 | 6f 72 74 28 74 68 65 57 |. SetP|ort(theW| |00003380| 69 6e 64 6f 77 29 3b 0d | 20 20 20 64 6f 20 7b 20 |indow);.| do { | |00003390| 2f 2f 20 49 6d 61 67 69 | 6e 65 20 68 65 72 65 20 |// Imagi|ne here | |000033a0| 74 68 61 74 20 79 6f 75 | 20 61 72 65 20 6f 6e 20 |that you| are on | |000033b0| 6f 6e 65 20 6c 65 76 65 | 6c 20 6f 66 20 74 68 65 |one leve|l of the| |000033c0| 20 72 65 63 75 72 73 69 | 6f 6e 2c 0d 20 20 20 20 | recursi|on,. | |000033d0| 20 20 20 20 2f 2f 20 61 | 6e 64 20 79 6f 75 20 68 | // a|nd you h| |000033e0| 61 76 65 20 6a 75 73 74 | 20 72 65 74 75 72 6e 65 |ave just| returne| |000033f0| 64 20 66 72 6f 6d 20 74 | 72 79 69 6e 67 20 61 6c |d from t|rying al| |00003400| 6c 20 74 68 65 20 70 6f | 73 73 69 62 69 6c 69 74 |l the po|ssibilit| |00003410| 69 65 73 0d 20 20 20 20 | 20 20 20 20 2f 2f 20 61 |ies. | // a| |00003420| 74 20 6f 74 68 65 72 20 | 6c 65 76 65 6c 73 2e 20 |t other |levels. | |00003430| 20 59 6f 75 20 77 61 6e | 74 20 74 6f 20 74 72 79 | You wan|t to try| |00003440| 20 74 68 65 20 6e 65 78 | 74 20 70 6f 73 73 69 62 | the nex|t possib| |00003450| 6c 65 20 70 69 65 63 65 | 0d 20 20 20 20 20 20 20 |le piece|. | |00003460| 20 2f 2f 20 6f 6e 20 74 | 68 69 73 20 6c 65 76 65 | // on t|his leve| |00003470| 6c 2e 20 20 54 68 61 74 | 20 69 73 20 77 68 61 74 |l. That| is what| |00003480| 20 69 73 20 64 6f 6e 65 | 20 62 79 20 74 68 69 73 | is done| by this| |00003490| 20 62 6f 64 79 20 6f 66 | 20 74 68 69 73 0d 20 20 | body of| this. | |000034a0| 20 20 20 20 20 20 2f 2f | 20 64 6f 20 6c 6f 6f 70 | //| do loop| |000034b0| 2c 20 65 78 63 65 70 74 | 20 74 68 61 74 20 69 74 |, except| that it| |000034c0| 20 61 6c 73 6f 20 68 61 | 6e 64 6c 65 73 20 74 68 | also ha|ndles th| |000034d0| 65 20 74 77 6f 20 65 78 | 74 72 65 6d 65 20 63 61 |e two ex|treme ca| |000034e0| 73 65 73 3a 0d 20 20 20 | 20 20 20 20 20 2f 2f 20 |ses:. | // | |000034f0| 77 68 65 6e 20 79 6f 75 | 20 66 69 72 73 74 20 67 |when you| first g| |00003500| 65 74 20 74 6f 20 74 68 | 69 73 20 6c 65 76 65 6c |et to th|is level| |00003510| 20 28 69 6e 64 69 63 61 | 74 65 64 20 62 79 20 61 | (indica|ted by a| |00003520| 20 76 61 6c 75 65 20 6f | 66 20 2d 31 0d 20 20 20 | value o|f -1. | |00003530| 20 20 20 20 20 2f 2f 20 | 69 6e 20 70 69 65 63 65 | // |in piece| |00003540| 53 74 61 63 6b 5b 70 6c | 61 79 65 64 5d 29 20 61 |Stack[pl|ayed]) a| |00003550| 6e 64 20 77 68 65 6e 20 | 74 68 65 72 65 20 61 72 |nd when |there ar| |00003560| 65 20 6e 6f 20 6f 74 68 | 65 72 20 70 69 65 63 65 |e no oth|er piece| |00003570| 73 20 74 6f 0d 20 20 20 | 20 20 20 20 20 2f 2f 20 |s to. | // | |00003580| 70 6c 61 79 20 28 69 6e | 64 69 63 61 74 65 64 20 |play (in|dicated | |00003590| 77 68 65 6e 20 70 69 65 | 63 65 4e 75 6d 20 62 65 |when pie|ceNum be| |000035a0| 63 6f 6d 65 73 20 36 33 | 2c 20 77 68 69 63 68 20 |comes 63|, which | |000035b0| 63 61 75 73 65 73 20 79 | 6f 75 0d 20 20 20 20 20 |causes y|ou. | |000035c0| 20 20 20 2f 2f 20 74 6f | 20 62 61 63 6b 20 75 70 | // to| back up| |000035d0| 20 6f 6e 65 20 6c 65 76 | 65 6c 20 61 6e 64 20 72 | one lev|el and r| |000035e0| 65 70 65 61 74 20 74 68 | 65 20 64 6f 20 6c 6f 6f |epeat th|e do loo| |000035f0| 70 20 6f 6e 20 74 68 61 | 74 20 6c 65 76 65 6c 29 |p on tha|t level)| |00003600| 3b 0d 20 20 20 20 20 20 | 20 20 2f 2f 20 49 66 20 |;. | // If | |00003610| 79 6f 75 20 62 61 63 6b | 20 75 70 20 61 6c 6c 20 |you back| up all | |00003620| 74 68 65 20 77 61 79 20 | 74 6f 20 74 68 65 20 74 |the way |to the t| |00003630| 6f 70 20 6c 65 76 65 6c | 2c 20 74 68 65 6e 20 79 |op level|, then y| |00003640| 6f 75 20 6b 6e 6f 77 0d | 20 20 20 20 20 20 20 20 |ou know.| | |00003650| 2f 2f 20 74 68 65 72 65 | 20 61 72 65 20 6e 6f 20 |// there| are no | |00003660| 73 6f 6c 75 74 69 6f 6e | 73 29 2e 0d 20 20 20 20 |solution|s).. | |00003670| 20 65 6d 70 74 79 53 71 | 75 61 72 65 20 3d 20 73 | emptySq|uare = s| |00003680| 71 75 61 72 65 53 74 61 | 63 6b 5b 70 6c 61 79 65 |quareSta|ck[playe| |00003690| 64 5d 3b 0d 20 20 20 20 | 20 69 66 20 28 70 69 65 |d];. | if (pie| |000036a0| 63 65 53 74 61 63 6b 5b | 70 6c 61 79 65 64 5d 20 |ceStack[|played] | |000036b0| 3e 20 2d 31 29 20 7b 20 | 20 2f 2f 20 72 65 6d 6f |> -1) { | // remo| |000036c0| 76 65 20 70 72 65 76 69 | 6f 75 73 20 70 69 65 63 |ve previ|ous piec| |000036d0| 65 20 74 72 69 65 64 2c | 20 69 66 20 61 6e 79 0d |e tried,| if any.| |000036e0| 20 20 20 20 20 20 20 20 | 20 20 46 6f 72 65 43 6f | | ForeCo| |000036f0| 6c 6f 72 28 77 68 69 74 | 65 43 6f 6c 6f 72 29 3b |lor(whit|eColor);| |00003700| 0d 20 20 20 20 20 20 20 | 20 20 20 65 72 61 73 65 |. | erase| |00003710| 50 69 65 63 65 28 70 69 | 65 63 65 53 74 61 63 6b |Piece(pi|eceStack| |00003720| 5b 70 6c 61 79 65 64 5d | 2c 73 71 75 61 72 65 53 |[played]|,squareS| |00003730| 74 61 63 6b 5b 70 6c 61 | 79 65 64 5d 2c 66 69 6c |tack[pla|yed],fil| |00003740| 6c 65 64 29 3b 0d 20 20 | 20 20 20 20 20 20 20 20 |led);. | | |00003750| 46 6f 72 65 43 6f 6c 6f | 72 28 62 6c 61 63 6b 43 |ForeColo|r(blackC| |00003760| 6f 6c 6f 72 29 3b 0d 20 | 20 20 20 20 20 20 20 20 |olor);. | | |00003770| 20 75 73 65 64 5b 70 69 | 65 63 65 73 5b 70 69 65 | used[pi|eces[pie| |00003780| 63 65 53 74 61 63 6b 5b | 70 6c 61 79 65 64 5d 5d |ceStack[|played]]| |00003790| 5b 30 5d 5d 20 3d 20 30 | 3b 0d 20 20 20 20 20 7d |[0]] = 0|;. }| |000037a0| 3b 0d 20 20 20 20 20 66 | 6f 72 20 28 70 69 65 63 |;. f|or (piec| |000037b0| 65 4e 75 6d 20 3d 20 70 | 69 65 63 65 53 74 61 63 |eNum = p|ieceStac| |000037c0| 6b 5b 70 6c 61 79 65 64 | 5d 2b 31 3b 20 0d 20 20 |k[played|]+1; . | |000037d0| 20 20 20 20 20 20 20 20 | 70 69 65 63 65 4e 75 6d | |pieceNum| |000037e0| 20 3c 20 36 33 20 26 26 | 20 0d 20 20 20 20 20 20 | < 63 &&| . | |000037f0| 20 20 20 20 20 20 28 75 | 73 65 64 5b 70 69 65 63 | (u|sed[piec| |00003800| 65 73 5b 70 69 65 63 65 | 4e 75 6d 5d 5b 30 5d 5d |es[piece|Num][0]]| |00003810| 20 7c 7c 20 21 70 75 74 | 50 69 65 63 65 28 70 69 | || !put|Piece(pi| |00003820| 65 63 65 4e 75 6d 2c 65 | 6d 70 74 79 53 71 75 61 |eceNum,e|mptySqua| |00003830| 72 65 2c 66 69 6c 6c 65 | 64 29 29 3b 0d 20 20 20 |re,fille|d));. | |00003840| 20 20 20 20 20 20 20 70 | 69 65 63 65 4e 75 6d 20 | p|ieceNum | |00003850| 2b 2b 29 3b 20 20 2f 2f | 20 69 6e 63 72 65 6d 65 |++); //| increme| |00003860| 6e 74 20 70 69 65 63 65 | 4e 75 6d 20 75 6e 74 69 |nt piece|Num unti| |00003870| 6c 20 79 6f 75 20 67 65 | 74 20 74 6f 20 61 20 70 |l you ge|t to a p| |00003880| 69 65 63 65 0d 20 20 20 | 20 20 20 20 20 20 20 20 |iece. | | |00003890| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 2f 2f | | //| |000038a0| 20 74 68 61 74 20 66 69 | 74 73 2c 20 6f 72 20 72 | that fi|ts, or r| |000038b0| 75 6e 20 6f 75 74 20 6f | 66 20 70 69 65 63 65 73 |un out o|f pieces| |000038c0| 0d 20 20 20 20 20 69 66 | 20 28 70 69 65 63 65 4e |. if| (pieceN| |000038d0| 75 6d 20 3e 3d 20 36 33 | 29 20 7b 20 20 2f 2f 20 |um >= 63|) { // | |000038e0| 69 66 20 79 6f 75 20 72 | 61 6e 20 6f 75 74 20 6f |if you r|an out o| |000038f0| 66 20 70 69 65 63 65 73 | 2c 20 62 61 63 6b 20 75 |f pieces|, back u| |00003900| 70 20 61 20 6c 65 76 65 | 6c 0d 20 20 20 20 20 20 |p a leve|l. | |00003910| 20 20 70 6c 61 79 65 64 | 2d 2d 3b 0d 20 20 20 20 | played|--;. | |00003920| 20 20 20 20 69 66 20 28 | 70 6c 61 79 65 64 20 3d | if (|played =| |00003930| 3d 20 2d 31 29 20 7b 0d | 20 20 20 20 20 20 20 20 |= -1) {.| | |00003940| 20 20 20 73 74 61 74 65 | 20 3d 20 6e 6f 53 6f 6c | state| = noSol| |00003950| 75 74 69 6f 6e 3b 0d 20 | 20 20 20 20 20 20 20 20 |ution;. | | |00003960| 20 20 53 65 74 54 69 74 | 6c 65 28 22 5c 70 4e 6f | SetTit|le("\pNo| |00003970| 20 53 6f 6c 75 74 69 6f | 6e 22 29 3b 0d 20 20 20 | Solutio|n");. | |00003980| 20 20 20 20 20 20 20 20 | 53 79 73 42 65 65 70 28 | |SysBeep(| |00003990| 32 29 3b 0d 20 20 20 20 | 20 20 20 20 20 20 20 72 |2);. | r| |000039a0| 65 74 75 72 6e 3b 0d 20 | 20 20 20 20 20 20 20 7d |eturn;. | }| |000039b0| 0d 20 20 20 20 20 7d 0d | 20 20 20 7d 20 77 68 69 |. }.| } whi| |000039c0| 6c 65 20 28 70 69 65 63 | 65 4e 75 6d 20 3e 3d 20 |le (piec|eNum >= | |000039d0| 36 33 29 3b 20 20 2f 2f | 20 72 65 70 65 61 74 20 |63); //| repeat | |000039e0| 69 66 20 64 69 64 6e 27 | 74 20 70 6c 61 79 20 61 |if didn'|t play a| |000039f0| 20 70 69 65 63 65 20 6f | 6e 20 74 68 69 73 20 6c | piece o|n this l| |00003a00| 65 76 65 6c 0d 20 20 20 | 70 69 65 63 65 53 74 61 |evel. |pieceSta| |00003a10| 63 6b 5b 70 6c 61 79 65 | 64 5d 20 3d 20 70 69 65 |ck[playe|d] = pie| |00003a20| 63 65 4e 75 6d 3b 20 20 | 2f 2f 20 72 65 63 6f 72 |ceNum; |// recor| |00003a30| 64 20 74 68 65 20 70 69 | 65 63 65 20 74 68 61 74 |d the pi|ece that| |00003a40| 20 77 61 73 20 70 6c 61 | 79 65 64 0d 20 20 20 75 | was pla|yed. u| |00003a50| 73 65 64 5b 70 69 65 63 | 65 73 5b 70 69 65 63 65 |sed[piec|es[piece| |00003a60| 4e 75 6d 5d 5b 30 5d 5d | 20 3d 20 31 3b 0d 20 20 |Num][0]]| = 1;. | |00003a70| 20 69 66 20 28 70 6c 61 | 79 65 64 20 3d 3d 20 31 | if (pla|yed == 1| |00003a80| 31 29 20 7b 20 20 2f 2f | 20 61 20 73 6f 6c 75 74 |1) { //| a solut| |00003a90| 69 6f 6e 20 77 61 73 20 | 66 6f 75 6e 64 0d 20 20 |ion was |found. | |00003aa0| 20 20 20 20 53 79 73 42 | 65 65 70 28 31 29 3b 0d | SysB|eep(1);.| |00003ab0| 20 20 20 20 20 20 53 79 | 73 42 65 65 70 28 31 29 | Sy|sBeep(1)| |00003ac0| 3b 0d 20 20 20 20 20 20 | 53 79 73 42 65 65 70 28 |;. |SysBeep(| |00003ad0| 31 29 3b 0d 20 20 20 20 | 20 20 53 65 74 54 69 74 |1);. | SetTit| |00003ae0| 6c 65 28 22 5c 70 43 6c | 69 63 6b 20 66 6f 72 20 |le("\pCl|ick for | |00003af0| 4d 6f 72 65 22 29 3b 0d | 20 20 20 20 20 20 73 74 |More");.| st| |00003b00| 61 74 65 20 3d 20 66 69 | 6e 69 73 68 65 64 3b 0d |ate = fi|nished;.| |00003b10| 20 20 20 7d 0d 20 20 20 | 65 6c 73 65 20 7b 20 20 | }. |else { | |00003b20| 2f 2f 20 54 68 69 73 20 | 72 65 61 6c 6c 79 20 73 |// This |really s| |00003b30| 65 74 73 20 75 70 20 61 | 20 73 69 6d 75 6c 61 74 |ets up a| simulat| |00003b40| 65 64 20 63 61 6c 6c 20 | 74 6f 20 74 68 65 20 72 |ed call |to the r| |00003b50| 65 63 75 72 73 69 76 65 | 0d 20 20 20 20 20 20 20 |ecursive|. | |00003b60| 20 20 20 20 2f 2f 20 61 | 6c 67 6f 72 69 74 68 6d | // a|lgorithm| |00003b70| 20 6f 6e 20 74 68 65 20 | 6e 65 78 74 20 6c 65 76 | on the |next lev| |00003b80| 65 6c 20 64 6f 77 6e 0d | 20 20 20 20 20 20 70 6c |el down.| pl| |00003b90| 61 79 65 64 2b 2b 3b 20 | 20 2f 2f 20 61 64 76 61 |ayed++; | // adva| |00003ba0| 6e 63 65 20 74 6f 20 6e | 65 78 74 20 6c 65 76 65 |nce to n|ext leve| |00003bb0| 6c 0d 20 20 20 20 20 20 | 70 69 65 63 65 53 74 61 |l. |pieceSta| |00003bc0| 63 6b 5b 70 6c 61 79 65 | 64 5d 20 3d 20 2d 31 3b |ck[playe|d] = -1;| |00003bd0| 20 20 2f 2f 20 6f 6e 20 | 74 68 65 20 6e 65 77 20 | // on |the new | |00003be0| 6c 65 76 65 6c 2c 20 6e | 6f 20 70 69 65 63 65 20 |level, n|o piece | |00003bf0| 68 61 73 20 62 65 65 6e | 20 74 72 69 65 64 0d 20 |has been| tried. | |00003c00| 20 20 20 20 20 77 68 69 | 6c 65 20 28 66 69 6c 6c | whi|le (fill| |00003c10| 65 64 5b 65 6d 70 74 79 | 53 71 75 61 72 65 5d 29 |ed[empty|Square])| |00003c20| 0d 20 20 20 20 20 20 20 | 20 20 65 6d 70 74 79 53 |. | emptyS| |00003c30| 71 75 61 72 65 2b 2b 3b | 20 20 2f 2f 20 66 69 6e |quare++;| // fin| |00003c40| 64 20 6f 75 74 20 77 68 | 69 63 68 20 69 73 20 74 |d out wh|ich is t| |00003c50| 68 65 20 6e 65 78 74 20 | 73 71 75 61 72 65 20 74 |he next |square t| |00003c60| 6f 20 62 65 20 66 69 6c | 6c 65 64 0d 20 20 20 20 |o be fil|led. | |00003c70| 20 20 73 71 75 61 72 65 | 53 74 61 63 6b 5b 70 6c | square|Stack[pl| |00003c80| 61 79 65 64 5d 20 3d 20 | 65 6d 70 74 79 53 71 75 |ayed] = |emptySqu| |00003c90| 61 72 65 3b 0d 20 20 20 | 7d 0d 7d 0d 0d 76 6f 69 |are;. |}.}..voi| |00003ca0| 64 20 6d 79 57 69 6e 64 | 6f 77 3a 3a 53 65 74 44 |d myWind|ow::SetD| |00003cb0| 65 66 61 75 6c 74 73 28 | 76 6f 69 64 29 20 7b 0d |efaults(|void) {.| |00003cc0| 20 20 20 73 68 6f 72 74 | 20 69 2c 6a 3b 0d 20 20 | short| i,j;. | |00003cd0| 20 69 6e 68 65 72 69 74 | 65 64 3a 3a 53 65 74 44 | inherit|ed::SetD| |00003ce0| 65 66 61 75 6c 74 73 28 | 29 3b 0d 20 20 20 66 65 |efaults(|);. fe| |00003cf0| 61 74 75 72 65 73 20 3d | 20 68 61 73 47 6f 41 77 |atures =| hasGoAw| |00003d00| 61 79 3b 20 20 2f 2f 20 | 54 68 65 20 77 69 6e 64 |ay; // |The wind| |00003d10| 6f 77 20 69 73 20 66 69 | 78 65 64 2d 73 69 7a 65 |ow is fi|xed-size| |00003d20| 20 77 69 74 68 20 6e 6f | 20 73 63 72 6f 6c 6c 20 | with no| scroll | |00003d30| 62 61 72 73 2e 0d 20 20 | 20 63 6c 69 63 6b 65 64 |bars.. | clicked| |00003d40| 20 3d 20 30 3b 20 20 20 | 20 20 20 20 20 20 2f 2f | = 0; | //| |00003d50| 20 49 6e 69 74 69 61 6c | 69 7a 65 20 77 69 6e 64 | Initial|ize wind| |00003d60| 6f 77 20 64 61 74 61 2e | 2e 2e 0d 20 20 20 73 74 |ow data.|... st| |00003d70| 61 74 65 20 3d 20 73 65 | 74 74 69 6e 67 55 70 3b |ate = se|ttingUp;| |00003d80| 20 0d 20 20 20 73 71 75 | 61 72 65 53 74 61 63 6b | . squ|areStack| |00003d90| 5b 30 5d 20 3d 20 31 31 | 3b 20 20 2f 2f 20 66 69 |[0] = 11|; // fi| |00003da0| 72 73 74 20 73 71 75 61 | 72 65 20 6f 6e 20 62 6f |rst squa|re on bo| |00003db0| 61 72 64 20 28 6e 6f 74 | 20 63 6f 75 6e 74 69 6e |ard (not| countin| |00003dc0| 67 20 62 6f 72 64 65 72 | 29 0d 20 20 20 70 6c 61 |g border|). pla| |00003dd0| 79 65 64 20 3d 20 30 3b | 20 20 20 20 20 20 20 20 |yed = 0;| | |00003de0| 20 20 20 2f 2f 20 6e 6f | 20 70 69 65 63 65 73 20 | // no| pieces | |00003df0| 70 6c 61 79 65 64 0d 20 | 20 20 70 69 65 63 65 53 |played. | pieceS| |00003e00| 74 61 63 6b 5b 30 5d 20 | 3d 20 2d 31 3b 20 20 20 |tack[0] |= -1; | |00003e10| 2f 2f 20 69 6e 64 69 63 | 61 74 65 73 20 74 68 61 |// indic|ates tha| |00003e20| 74 20 6e 6f 20 70 69 65 | 63 65 73 20 68 61 76 65 |t no pie|ces have| |00003e30| 20 62 65 65 6e 20 74 72 | 69 65 64 20 79 65 74 20 | been tr|ied yet | |00003e40| 65 69 74 68 65 72 0d 20 | 20 20 66 6f 72 20 28 69 |either. | for (i| |00003e50| 3d 30 3b 20 69 3c 31 30 | 30 3b 20 69 2b 2b 29 20 |=0; i<10|0; i++) | |00003e60| 2f 2f 20 66 69 6c 6c 20 | 69 6e 20 74 68 65 20 62 |// fill |in the b| |00003e70| 6f 72 64 65 72 20 77 69 | 74 68 20 2d 31 27 73 0d |order wi|th -1's.| |00003e80| 20 20 20 20 20 66 69 6c | 6c 65 64 5b 69 5d 20 3d | fil|led[i] =| |00003e90| 20 2d 31 3b 0d 20 20 20 | 66 6f 72 20 28 69 3d 31 | -1;. |for (i=1| |00003ea0| 3b 20 69 3c 39 3b 20 69 | 2b 2b 29 20 20 20 2f 2f |; i<9; i|++) //| |00003eb0| 20 66 69 6c 6c 20 69 6e | 20 74 68 65 20 72 65 73 | fill in| the res| |00003ec0| 74 20 6f 66 20 74 68 65 | 20 62 6f 61 72 64 20 77 |t of the| board w| |00003ed0| 69 74 68 20 65 6d 70 74 | 79 20 73 70 61 63 65 73 |ith empt|y spaces| |00003ee0| 20 28 30 27 73 29 0d 20 | 20 20 20 20 66 6f 72 20 | (0's). | for | |00003ef0| 28 6a 3d 31 3b 20 6a 3c | 39 3b 20 6a 2b 2b 29 0d |(j=1; j<|9; j++).| |00003f00| 20 20 20 20 20 20 20 20 | 66 69 6c 6c 65 64 5b 6a | |filled[j| |00003f10| 2a 31 30 2b 69 5d 20 3d | 20 30 3b 0d 20 20 20 66 |*10+i] =| 0;. f| |00003f20| 6f 72 20 28 69 3d 31 3b | 69 3c 31 33 3b 69 2b 2b |or (i=1;|i<13;i++| |00003f30| 29 20 20 20 2f 2f 20 66 | 6f 72 20 65 61 63 68 20 |) // f|or each | |00003f40| 70 65 6e 74 6f 6d 69 6e | 6f 2c 20 72 65 63 6f 72 |pentomin|o, recor| |00003f50| 64 20 74 68 61 74 20 69 | 74 20 68 61 73 20 6e 6f |d that i|t has no| |00003f60| 74 20 62 65 65 6e 20 75 | 73 65 64 0d 20 20 20 20 |t been u|sed. | |00003f70| 20 20 75 73 65 64 5b 69 | 5d 20 3d 20 30 3b 0d 7d | used[i|] = 0;.}| |00003f80| 0d 0d 0d 2f 2f 20 46 75 | 6e 63 74 69 6f 6e 20 4f |...// Fu|nction O| |00003f90| 70 65 6e 49 6e 52 65 63 | 74 20 68 61 73 20 62 65 |penInRec|t has be| |00003fa0| 65 6e 20 6d 6f 64 69 66 | 69 65 64 20 74 6f 20 69 |en modif|ied to i| |00003fb0| 67 6e 6f 72 65 20 74 68 | 65 20 70 61 72 61 6d 65 |gnore th|e parame| |00003fc0| 74 65 72 73 20 74 68 61 | 74 20 67 69 76 65 0d 2f |ters tha|t give./| |00003fd0| 2f 20 74 68 65 20 77 69 | 6e 64 6f 77 20 70 6f 73 |/ the wi|ndow pos| |00003fe0| 69 74 69 6f 6e 20 61 6e | 64 20 74 6f 20 75 73 65 |ition an|d to use| |00003ff0| 20 61 20 66 6f 72 6d 75 | 6c 61 20 6f 66 20 6d 79 | a formu|la of my| |00004000| 20 6f 77 6e 20 74 6f 20 | 73 65 74 20 75 70 20 74 | own to |set up t| |00004010| 68 65 0d 2f 2f 20 77 69 | 6e 64 6f 77 20 6c 6f 63 |he.// wi|ndow loc| |00004020| 61 74 69 6f 6e 2e 20 20 | 54 68 65 20 77 69 6e 64 |ation. |The wind| |00004030| 6f 77 73 20 61 72 65 20 | 61 6c 6c 20 74 68 65 20 |ows are |all the | |00004040| 73 61 6d 65 20 73 69 7a | 65 20 61 6e 64 20 65 61 |same siz|e and ea| |00004050| 63 68 20 73 75 63 63 65 | 73 73 69 76 65 0d 2f 2f |ch succe|ssive.//| |00004060| 20 77 69 6e 64 6f 77 73 | 20 69 73 20 6f 66 66 73 | windows| is offs| |00004070| 65 74 20 66 72 6f 6d 20 | 74 68 65 20 70 72 65 76 |et from |the prev| |00004080| 69 6f 75 73 20 77 69 6e | 64 6f 77 2e 20 20 57 69 |ious win|dow. Wi| |00004090| 6e 64 6f 77 43 74 20 69 | 73 20 61 20 67 6c 6f 62 |ndowCt i|s a glob| |000040a0| 61 6c 0d 2f 2f 20 76 61 | 72 69 61 62 6c 65 20 74 |al.// va|riable t| |000040b0| 68 61 74 20 74 65 6c 6c | 73 20 68 6f 77 20 6d 61 |hat tell|s how ma| |000040c0| 6e 79 20 77 69 6e 64 6f | 77 73 20 68 61 76 65 20 |ny windo|ws have | |000040d0| 62 65 65 6e 20 6f 70 65 | 6e 65 64 20 73 6f 20 66 |been ope|ned so f| |000040e0| 61 72 2e 0d 0d 76 6f 69 | 64 20 6d 79 57 69 6e 64 |ar...voi|d myWind| |000040f0| 6f 77 3a 3a 4f 70 65 6e | 49 6e 52 65 63 74 28 53 |ow::Open|InRect(S| |00004100| 74 72 32 35 35 20 74 69 | 74 6c 65 2c 20 69 6e 74 |tr255 ti|tle, int| |00004110| 20 6c 65 66 74 2c 20 69 | 6e 74 20 74 6f 70 2c 20 | left, i|nt top, | |00004120| 69 6e 74 20 72 69 67 68 | 74 2c 20 69 6e 74 20 62 |int righ|t, int b| |00004130| 6f 74 74 6f 6d 29 20 7b | 0d 20 20 20 69 6e 68 65 |ottom) {|. inhe| |00004140| 72 69 74 65 64 3a 3a 4f | 70 65 6e 49 6e 52 65 63 |rited::O|penInRec| |00004150| 74 28 74 69 74 6c 65 2c | 0d 20 20 20 20 20 20 20 |t(title,|. | |00004160| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004170| 20 20 34 30 2b 31 30 2a | 28 57 69 6e 64 6f 77 43 | 40+10*|(WindowC| |00004180| 74 25 32 35 29 2c 0d 20 | 20 20 20 20 20 20 20 20 |t%25),. | | |00004190| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |000041a0| 35 35 2b 31 30 2a 28 57 | 69 6e 64 6f 77 43 74 25 |55+10*(W|indowCt%| |000041b0| 31 30 29 2c 0d 20 20 20 | 20 20 20 20 20 20 20 20 |10),. | | |000041c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 34 30 | | 40| |000041d0| 2b 38 2a 73 71 75 61 72 | 65 53 69 7a 65 2d 31 2b |+8*squar|eSize-1+| |000041e0| 31 30 2a 28 57 69 6e 64 | 6f 77 43 74 25 32 35 29 |10*(Wind|owCt%25)| |000041f0| 2c 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |,. | | |00004200| 20 20 20 20 20 20 20 20 | 20 20 20 35 35 2b 38 2a | | 55+8*| |00004210| 73 71 75 61 72 65 53 69 | 7a 65 2d 31 2b 31 30 2a |squareSi|ze-1+10*| |00004220| 28 57 69 6e 64 6f 77 43 | 74 25 31 30 29 29 3b 0d |(WindowC|t%10));.| |00004230| 7d 0d 0d 73 68 6f 72 74 | 20 6d 79 57 69 6e 64 6f |}..short| myWindo| |00004240| 77 3a 3a 43 6c 6f 73 65 | 28 76 6f 69 64 29 20 7b |w::Close|(void) {| |00004250| 0d 20 20 20 69 6e 68 65 | 72 69 74 65 64 3a 3a 43 |. inhe|rited::C| |00004260| 6c 6f 73 65 28 29 3b 0d | 7d 0d 0d 0d 2f 2f 20 48 |lose();.|}...// H| |00004270| 65 72 65 20 69 73 20 61 | 20 66 65 61 74 75 72 65 |ere is a| feature| |00004280| 20 74 68 61 74 20 69 73 | 20 75 6e 64 6f 63 75 6d | that is| undocum| |00004290| 65 6e 74 65 64 20 65 6c | 73 65 77 68 65 72 65 3a |ented el|sewhere:| |000042a0| 20 20 49 66 20 74 68 65 | 20 75 73 65 72 20 68 69 | If the| user hi| |000042b0| 74 73 20 61 6e 79 0d 2f | 2f 20 6b 65 79 20 62 65 |ts any./|/ key be| |000042c0| 66 6f 72 65 20 63 6c 69 | 63 6b 69 6e 67 20 6f 6e |fore cli|cking on| |000042d0| 20 66 6f 75 72 20 73 71 | 75 61 72 65 73 2c 20 74 | four sq|uares, t| |000042e0| 68 65 20 70 72 6f 67 72 | 61 6d 20 77 69 6c 6c 20 |he progr|am will | |000042f0| 73 74 61 72 74 20 73 6f | 6c 76 69 6e 67 20 74 68 |start so|lving th| |00004300| 65 0d 2f 2f 20 70 75 7a | 7a 6c 65 3b 20 74 68 65 |e.// puz|zle; the| |00004310| 72 65 20 77 69 6c 6c 20 | 62 65 20 73 6f 6d 65 20 |re will |be some | |00004320| 65 78 74 72 61 20 65 6d | 70 74 79 20 73 71 75 61 |extra em|pty squa| |00004330| 72 65 73 20 6f 6e 20 74 | 68 65 20 62 6f 61 72 64 |res on t|he board| |00004340| 20 61 66 74 65 72 20 61 | 6c 6c 20 31 32 0d 2f 2f | after a|ll 12.//| |00004350| 20 70 65 6e 74 6f 6d 69 | 6e 6f 73 20 68 61 76 65 | pentomi|nos have| |00004360| 20 62 65 65 6e 20 70 6c | 61 63 65 64 2e 0d 0d 76 | been pl|aced...v| |00004370| 6f 69 64 20 6d 79 57 69 | 6e 64 6f 77 3a 3a 64 6f |oid myWi|ndow::do| |00004380| 4b 65 79 28 63 68 61 72 | 20 63 68 29 20 7b 0d 20 |Key(char| ch) {. | |00004390| 20 20 69 66 20 28 73 74 | 61 74 65 20 3e 3d 20 72 | if (st|ate >= r| |000043a0| 75 6e 6e 69 6e 67 29 0d | 20 20 20 20 20 20 72 65 |unning).| re| |000043b0| 74 75 72 6e 3b 0d 20 20 | 20 73 74 61 74 65 20 3d |turn;. | state =| |000043c0| 20 72 75 6e 6e 69 6e 67 | 3b 0d 20 20 20 77 68 69 | running|;. whi| |000043d0| 6c 65 20 28 66 69 6c 6c | 65 64 5b 73 71 75 61 72 |le (fill|ed[squar| |000043e0| 65 53 74 61 63 6b 5b 30 | 5d 5d 29 0d 20 20 20 20 |eStack[0|]]). | |000043f0| 20 20 20 73 71 75 61 72 | 65 53 74 61 63 6b 5b 30 | squar|eStack[0| |00004400| 5d 2b 2b 3b 0d 20 20 20 | 53 65 74 54 69 74 6c 65 |]++;. |SetTitle| |00004410| 28 22 5c 70 50 65 6e 74 | 6f 6d 69 6e 6f 73 22 29 |("\pPent|ominos")| |00004420| 3b 0d 20 20 20 63 6c 69 | 63 6b 65 64 20 3d 20 34 |;. cli|cked = 4| |00004430| 3b 0d 7d 0d 0d 0d 0d 76 | 6f 69 64 20 6d 79 57 69 |;.}....v|oid myWi| |00004440| 6e 64 6f 77 3a 3a 64 6f | 43 6f 6e 74 65 6e 74 43 |ndow::do|ContentC| |00004450| 6c 69 63 6b 28 50 6f 69 | 6e 74 20 6c 6f 63 61 6c |lick(Poi|nt local| |00004460| 50 74 29 20 7b 0d 20 20 | 20 73 68 6f 72 74 20 69 |Pt) {. | short i| |00004470| 2c 6a 3b 0d 20 20 20 52 | 65 63 74 20 52 3b 0d 20 |,j;. R|ect R;. | |00004480| 20 20 69 66 20 28 73 74 | 61 74 65 20 3d 3d 20 66 | if (st|ate == f| |00004490| 69 6e 69 73 68 65 64 29 | 20 7b 20 20 20 20 2f 2f |inished)| { //| |000044a0| 20 41 66 74 65 72 20 61 | 20 73 6f 6c 75 74 69 6f | After a| solutio| |000044b0| 6e 20 68 61 73 20 62 65 | 65 6e 20 66 6f 75 6e 64 |n has be|en found| |000044c0| 2c 20 74 68 65 20 75 73 | 65 72 0d 20 20 20 20 20 |, the us|er. | |000044d0| 20 73 74 61 74 65 20 3d | 20 72 75 6e 6e 69 6e 67 | state =| running| |000044e0| 3b 20 20 20 20 20 20 20 | 20 20 2f 2f 20 63 61 6e |; | // can| |000044f0| 20 72 65 73 74 61 72 74 | 20 74 68 65 20 73 65 61 | restart| the sea| |00004500| 72 63 68 20 66 6f 72 20 | 61 6e 6f 74 68 65 72 20 |rch for |another | |00004510| 73 6f 6c 75 74 69 6f 6e | 0d 20 20 20 20 20 20 53 |solution|. S| |00004520| 65 74 54 69 74 6c 65 28 | 22 5c 70 50 65 6e 74 6f |etTitle(|"\pPento| |00004530| 6d 69 6e 6f 73 22 29 3b | 2f 2f 20 62 79 20 63 6c |minos");|// by cl| |00004540| 69 63 6b 69 6e 67 20 6f | 6e 20 74 68 65 20 77 69 |icking o|n the wi| |00004550| 6e 64 6f 77 2e 20 28 4e | 6f 74 65 20 74 68 61 74 |ndow. (N|ote that| |00004560| 20 74 68 65 0d 20 20 20 | 20 20 20 72 65 74 75 72 | the. | retur| |00004570| 6e 3b 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |n; | | |00004580| 20 20 20 20 2f 2f 20 74 | 69 74 6c 65 20 6f 66 20 | // t|itle of | |00004590| 74 68 65 20 77 69 6e 64 | 6f 77 20 64 65 70 65 6e |the wind|ow depen| |000045a0| 64 73 20 6f 6e 20 74 68 | 65 20 63 75 72 72 65 6e |ds on th|e curren| |000045b0| 74 20 73 74 61 74 65 2e | 29 0d 20 20 20 7d 3b 0d |t state.|). };.| |000045c0| 20 20 20 69 66 20 28 73 | 74 61 74 65 20 3d 3d 20 | if (s|tate == | |000045d0| 73 65 74 74 69 6e 67 55 | 70 29 20 7b 20 20 20 2f |settingU|p) { /| |000045e0| 2f 20 66 69 6e 64 20 77 | 68 69 63 68 20 73 71 75 |/ find w|hich squ| |000045f0| 61 72 65 20 74 68 65 20 | 75 73 65 72 20 63 6c 69 |are the |user cli| |00004600| 63 6b 65 64 20 6f 6e 2c | 20 61 6e 64 0d 20 20 20 |cked on,| and. | |00004610| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004620| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2f 20 74 | | // t| |00004630| 6f 67 67 6c 65 20 69 74 | 73 20 73 74 61 74 65 20 |oggle it|s state | |00004640| 28 66 75 6c 6c 20 74 6f | 20 65 6d 70 74 79 20 74 |(full to| empty t| |00004650| 6f 20 65 6d 70 74 79 20 | 74 6f 20 66 75 6c 6c 29 |o empty |to full)| |00004660| 0d 20 20 20 20 20 20 6a | 20 3d 20 6c 6f 63 61 6c |. j| = local| |00004670| 50 74 2e 68 20 2f 20 73 | 71 75 61 72 65 53 69 7a |Pt.h / s|quareSiz| |00004680| 65 20 2b 20 31 3b 0d 20 | 20 20 20 20 20 69 20 3d |e + 1;. | i =| |00004690| 20 6c 6f 63 61 6c 50 74 | 2e 76 20 2f 20 73 71 75 | localPt|.v / squ| |000046a0| 61 72 65 53 69 7a 65 20 | 2b 20 31 3b 0d 20 20 20 |areSize |+ 1;. | |000046b0| 20 20 20 53 65 74 52 65 | 63 74 28 26 52 2c 28 6a | SetRe|ct(&R,(j| |000046c0| 2d 31 29 2a 73 71 75 61 | 72 65 53 69 7a 65 2c 28 |-1)*squa|reSize,(| |000046d0| 69 2d 31 29 2a 73 71 75 | 61 72 65 53 69 7a 65 2c |i-1)*squ|areSize,| |000046e0| 6a 2a 73 71 75 61 72 65 | 53 69 7a 65 2d 31 2c 69 |j*square|Size-1,i| |000046f0| 2a 73 71 75 61 72 65 53 | 69 7a 65 2d 31 29 3b 0d |*squareS|ize-1);.| |00004700| 20 20 20 20 20 20 49 6e | 76 65 72 74 52 65 63 74 | In|vertRect| |00004710| 28 26 52 29 3b 0d 20 20 | 20 20 20 20 66 69 6c 6c |(&R);. | fill| |00004720| 65 64 5b 69 2a 31 30 2b | 6a 5d 20 3d 20 31 20 2d |ed[i*10+|j] = 1 -| |00004730| 20 66 69 6c 6c 65 64 5b | 69 2a 31 30 2b 6a 5d 3b | filled[|i*10+j];| |00004740| 0d 20 20 20 20 20 20 69 | 66 20 28 66 69 6c 6c 65 |. i|f (fille| |00004750| 64 5b 69 2a 31 30 2b 6a | 5d 29 0d 20 20 20 20 20 |d[i*10+j|]). | |00004760| 20 20 20 20 63 6c 69 63 | 6b 65 64 2b 2b 3b 0d 20 | clic|ked++;. | |00004770| 20 20 20 20 20 65 6c 73 | 65 0d 20 20 20 20 20 20 | els|e. | |00004780| 20 20 20 63 6c 69 63 6b | 65 64 2d 2d 3b 0d 20 20 | click|ed--;. | |00004790| 20 20 20 20 69 66 20 28 | 63 6c 69 63 6b 65 64 20 | if (|clicked | |000047a0| 3d 3d 20 34 29 20 7b 20 | 20 20 2f 2f 20 54 68 65 |== 4) { | // The| |000047b0| 20 66 6f 75 72 74 68 20 | 73 70 61 63 65 20 68 61 | fourth |space ha| |000047c0| 73 20 6a 75 73 74 20 62 | 65 65 6e 20 73 70 65 63 |s just b|een spec| |000047d0| 69 66 69 65 64 3b 20 73 | 74 61 72 74 20 72 75 6e |ified; s|tart run| |000047e0| 6e 69 6e 67 0d 20 20 20 | 20 20 20 20 20 20 53 65 |ning. | Se| |000047f0| 74 54 69 74 6c 65 28 22 | 5c 70 50 65 6e 74 6f 6d |tTitle("|\pPentom| |00004800| 69 6e 6f 73 22 29 3b 0d | 20 20 20 20 20 20 20 20 |inos");.| | |00004810| 20 73 74 61 74 65 20 3d | 20 72 75 6e 6e 69 6e 67 | state =| running| |00004820| 3b 0d 20 20 20 20 20 20 | 20 20 20 77 68 69 6c 65 |;. | while| |00004830| 20 28 66 69 6c 6c 65 64 | 5b 73 71 75 61 72 65 53 | (filled|[squareS| |00004840| 74 61 63 6b 5b 30 5d 5d | 29 0d 20 20 20 20 20 20 |tack[0]]|). | |00004850| 20 20 20 20 20 20 73 71 | 75 61 72 65 53 74 61 63 | sq|uareStac| |00004860| 6b 5b 30 5d 2b 2b 3b 20 | 20 2f 2f 20 28 73 71 75 |k[0]++; | // (squ| |00004870| 61 72 65 53 74 61 63 6b | 5b 30 5d 20 69 73 20 73 |areStack|[0] is s| |00004880| 75 70 70 6f 73 65 64 20 | 74 6f 20 62 65 20 74 68 |upposed |to be th| |00004890| 65 20 66 69 72 73 74 0d | 20 20 20 20 20 20 20 20 |e first.| | |000048a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |000048b0| 20 20 20 20 20 20 20 2f | 2f 20 20 61 76 61 69 6c | /|/ avail| |000048c0| 61 62 6c 65 20 73 71 75 | 61 72 65 3b 20 74 68 65 |able squ|are; the| |000048d0| 20 75 73 65 72 20 6d 69 | 67 68 74 20 68 61 76 65 | user mi|ght have| |000048e0| 20 65 6c 69 6d 69 6e 61 | 74 65 64 0d 20 20 20 20 | elimina|ted. | |000048f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004900| 20 20 20 20 20 20 20 20 | 20 20 20 2f 2f 20 20 6f | | // o| |00004910| 6e 65 20 6f 72 20 6d 6f | 72 65 20 73 71 75 61 72 |ne or mo|re squar| |00004920| 65 73 20 61 74 20 74 68 | 65 20 62 65 67 69 6e 6e |es at th|e beginn| |00004930| 69 6e 67 20 6f 66 20 74 | 68 65 0d 20 20 20 20 20 |ing of t|he. | |00004940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004950| 20 20 20 20 20 20 20 20 | 20 20 2f 2f 20 20 62 6f | | // bo| |00004960| 61 72 64 2e 29 0d 20 20 | 20 20 20 20 7d 0d 20 20 |ard.). | }. | |00004970| 20 7d 0d 7d 0d 0d 0d 0d | 2f 2f 20 46 75 6e 63 74 | }.}....|// Funct| |00004980| 69 6f 6e 20 64 6f 52 65 | 64 72 61 77 20 73 69 6d |ion doRe|draw sim| |00004990| 70 6c 79 20 72 65 64 72 | 61 77 73 20 74 68 65 20 |ply redr|aws the | |000049a0| 62 6f 61 72 64 20 61 73 | 20 69 74 20 63 75 72 72 |board as| it curr| |000049b0| 65 6e 74 6c 79 20 65 78 | 69 73 74 73 2e 0d 0d 76 |ently ex|ists...v| |000049c0| 6f 69 64 20 6d 79 57 69 | 6e 64 6f 77 3a 3a 64 6f |oid myWi|ndow::do| |000049d0| 52 65 64 72 61 77 28 52 | 65 63 74 2a 20 62 61 64 |Redraw(R|ect* bad| |000049e0| 52 65 63 74 29 7b 0d 20 | 20 20 52 65 63 74 20 52 |Rect){. | Rect R| |000049f0| 3b 0d 20 20 20 73 68 6f | 72 74 20 69 2c 6a 3b 0d |;. sho|rt i,j;.| |00004a00| 20 20 20 66 6f 72 20 28 | 69 3d 31 3b 69 3c 38 3b | for (|i=1;i<8;| |00004a10| 69 2b 2b 29 20 7b 20 20 | 20 2f 2f 20 64 72 61 77 |i++) { | // draw| |00004a20| 20 76 65 72 74 69 63 61 | 6c 20 6c 69 6e 65 73 0d | vertica|l lines.| |00004a30| 20 20 20 20 20 20 4d 6f | 76 65 54 6f 28 69 2a 73 | Mo|veTo(i*s| |00004a40| 71 75 61 72 65 53 69 7a | 65 2d 31 2c 30 29 3b 0d |quareSiz|e-1,0);.| |00004a50| 20 20 20 20 20 20 4c 69 | 6e 65 28 30 2c 38 2a 73 | Li|ne(0,8*s| |00004a60| 71 75 61 72 65 53 69 7a | 65 29 3b 0d 20 20 20 7d |quareSiz|e);. }| |00004a70| 3b 0d 20 20 20 66 6f 72 | 20 28 6a 3d 31 3b 6a 3c |;. for| (j=1;j<| |00004a80| 38 3b 6a 2b 2b 29 20 7b | 20 20 20 2f 2f 20 64 72 |8;j++) {| // dr| |00004a90| 61 77 20 68 6f 72 69 7a | 6f 6e 74 61 6c 20 6c 69 |aw horiz|ontal li| |00004aa0| 6e 65 73 0d 20 20 20 20 | 20 20 4d 6f 76 65 54 6f |nes. | MoveTo| |00004ab0| 28 30 2c 6a 2a 73 71 75 | 61 72 65 53 69 7a 65 2d |(0,j*squ|areSize-| |00004ac0| 31 29 3b 0d 20 20 20 20 | 20 20 4c 69 6e 65 28 38 |1);. | Line(8| |00004ad0| 2a 73 71 75 61 72 65 53 | 69 7a 65 2c 30 29 3b 0d |*squareS|ize,0);.| |00004ae0| 20 20 20 7d 3b 0d 20 20 | 20 66 6f 72 20 28 69 3d | };. | for (i=| |00004af0| 31 3b 69 3c 39 3b 69 2b | 2b 29 0d 20 20 20 20 20 |1;i<9;i+|+). | |00004b00| 20 66 6f 72 20 28 6a 3d | 31 3b 6a 3c 39 3b 6a 2b | for (j=|1;j<9;j+| |00004b10| 2b 29 20 7b 20 20 20 2f | 2f 20 66 69 6c 6c 20 69 |+) { /|/ fill i| |00004b20| 6e 20 73 71 75 61 72 65 | 73 20 61 73 20 61 70 70 |n square|s as app| |00004b30| 72 6f 70 72 69 61 74 65 | 0d 20 20 20 20 20 20 20 |ropriate|. | |00004b40| 20 20 69 66 20 28 66 69 | 6c 6c 65 64 5b 6a 2a 31 | if (fi|lled[j*1| |00004b50| 30 2b 69 5d 20 3d 3d 20 | 31 29 20 7b 0d 20 20 20 |0+i] == |1) {. | |00004b60| 20 20 20 20 20 20 20 20 | 20 53 65 74 52 65 63 74 | | SetRect| |00004b70| 28 26 52 2c 28 69 2d 31 | 29 2a 73 71 75 61 72 65 |(&R,(i-1|)*square| |00004b80| 53 69 7a 65 2c 28 6a 2d | 31 29 2a 73 71 75 61 72 |Size,(j-|1)*squar| |00004b90| 65 53 69 7a 65 2c 69 2a | 73 71 75 61 72 65 53 69 |eSize,i*|squareSi| |00004ba0| 7a 65 2d 31 2c 6a 2a 73 | 71 75 61 72 65 53 69 7a |ze-1,j*s|quareSiz| |00004bb0| 65 2d 31 29 3b 0d 20 20 | 20 20 20 20 20 20 20 20 |e-1);. | | |00004bc0| 20 20 50 61 69 6e 74 52 | 65 63 74 28 26 52 29 3b | PaintR|ect(&R);| |00004bd0| 0d 20 20 20 20 20 20 20 | 20 20 7d 0d 20 20 20 20 |. | }. | |00004be0| 20 20 20 20 20 65 6c 73 | 65 20 69 66 20 28 66 69 | els|e if (fi| |00004bf0| 6c 6c 65 64 5b 6a 2a 31 | 30 2b 69 5d 29 20 7b 0d |lled[j*1|0+i]) {.| |00004c00| 20 20 20 20 20 20 20 20 | 20 20 20 20 4d 6f 76 65 | | Move| |00004c10| 54 6f 28 28 69 2d 31 29 | 2a 73 71 75 61 72 65 53 |To((i-1)|*squareS| |00004c20| 69 7a 65 2b 38 2c 28 6a | 2d 31 29 2a 73 71 75 61 |ize+8,(j|-1)*squa| |00004c30| 72 65 53 69 7a 65 2b 31 | 34 29 3b 0d 20 20 20 20 |reSize+1|4);. | |00004c40| 20 20 20 20 20 20 20 20 | 44 72 61 77 43 68 61 72 | |DrawChar| |00004c50| 28 66 69 6c 6c 65 64 5b | 6a 2a 31 30 2b 69 5d 29 |(filled[|j*10+i])| |00004c60| 3b 0d 20 20 20 20 20 20 | 20 20 20 7d 0d 20 20 20 |;. | }. | |00004c70| 20 20 20 7d 0d 7d 0d 0d | 76 6f 69 64 20 6d 79 57 | }.}..|void myW| |00004c80| 69 6e 64 6f 77 3a 3a 61 | 64 6a 75 73 74 54 6f 4e |indow::a|djustToN| |00004c90| 65 77 53 69 7a 65 28 76 | 6f 69 64 29 20 7b 0d 20 |ewSize(v|oid) {. | |00004ca0| 20 20 69 6e 68 65 72 69 | 74 65 64 3a 3a 61 64 6a | inheri|ted::adj| |00004cb0| 75 73 74 54 6f 4e 65 77 | 53 69 7a 65 28 29 3b 0d |ustToNew|Size();.| |00004cc0| 7d 0d 0d 76 6f 69 64 20 | 6d 79 57 69 6e 64 6f 77 |}..void |myWindow| |00004cd0| 3a 3a 64 6f 48 53 63 72 | 6f 6c 6c 28 69 6e 74 20 |::doHScr|oll(int | |00004ce0| 64 68 29 20 7b 0d 20 20 | 20 69 6e 68 65 72 69 74 |dh) {. | inherit| |00004cf0| 65 64 3a 3a 64 6f 48 53 | 63 72 6f 6c 6c 28 64 68 |ed::doHS|croll(dh| |00004d00| 29 3b 0d 7d 0d 0d 76 6f | 69 64 20 6d 79 57 69 6e |);.}..vo|id myWin| |00004d10| 64 6f 77 3a 3a 64 6f 56 | 53 63 72 6f 6c 6c 28 69 |dow::doV|Scroll(i| |00004d20| 6e 74 20 64 76 29 20 7b | 0d 20 20 20 69 6e 68 65 |nt dv) {|. inhe| |00004d30| 72 69 74 65 64 3a 3a 64 | 6f 56 53 63 72 6f 6c 6c |rited::d|oVScroll| |00004d40| 28 64 76 29 3b 0d 7d 0d | 0d 76 6f 69 64 20 6d 79 |(dv);.}.|.void my| |00004d50| 57 69 6e 64 6f 77 3a 3a | 64 6f 41 63 74 69 76 61 |Window::|doActiva| |00004d60| 74 65 28 69 6e 74 20 61 | 63 74 69 76 65 29 20 7b |te(int a|ctive) {| |00004d70| 0d 20 20 20 69 6e 68 65 | 72 69 74 65 64 3a 3a 64 |. inhe|rited::d| |00004d80| 6f 41 63 74 69 76 61 74 | 65 28 61 63 74 69 76 65 |oActivat|e(active| |00004d90| 29 3b 0d 7d 0d 0d 0d 0d | 76 6f 69 64 20 49 6e 69 |);.}....|void Ini| |00004da0| 74 41 70 70 6c 69 63 61 | 74 69 6f 6e 28 76 6f 69 |tApplica|tion(voi| |00004db0| 64 29 20 7b 0d 20 20 4d | 65 6e 75 48 61 6e 64 6c |d) {. M|enuHandl| |00004dc0| 65 20 61 70 70 6c 65 4d | 65 6e 75 3b 0d 20 20 66 |e appleM|enu;. f| |00004dd0| 69 6c 65 4d 65 6e 75 20 | 3d 20 47 65 74 4d 48 61 |ileMenu |= GetMHa| |00004de0| 6e 64 6c 65 28 32 29 3b | 0d 20 20 65 64 69 74 4d |ndle(2);|. editM| |00004df0| 65 6e 75 20 3d 20 47 65 | 74 4d 48 61 6e 64 6c 65 |enu = Ge|tMHandle| |00004e00| 28 33 29 3b 0d 20 20 61 | 70 70 6c 65 4d 65 6e 75 |(3);. a|ppleMenu| |00004e10| 20 3d 20 47 65 74 4d 48 | 61 6e 64 6c 65 28 31 29 | = GetMH|andle(1)| |00004e20| 3b 0d 20 20 53 65 74 49 | 74 65 6d 28 61 70 70 6c |;. SetI|tem(appl| |00004e30| 65 4d 65 6e 75 2c 31 2c | 22 5c 70 41 62 6f 75 74 |eMenu,1,|"\pAbout| |00004e40| 20 50 65 6e 74 6f 6d 69 | 6e 6f 73 2e 2e 2e 22 29 | Pentomi|nos...")| |00004e50| 3b 20 20 2f 2f 20 53 65 | 74 20 74 68 65 20 70 72 |; // Se|t the pr| |00004e60| 6f 67 72 61 6d 20 6e 61 | 6d 65 0d 20 20 20 20 20 |ogram na|me. | |00004e70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004e80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00004e90| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2f 20 66 | | // f| |00004ea0| 6f 72 20 66 69 72 73 74 | 20 6c 69 6e 65 20 6f 66 |or first| line of| |00004eb0| 20 41 70 70 6c 65 20 6d | 65 6e 75 0d 20 20 44 6f | Apple m|enu. Do| |00004ec0| 4e 65 77 43 6f 6d 6d 61 | 6e 64 28 29 3b 0d 7d 0d |NewComma|nd();.}.| |00004ed0| 0d 76 6f 69 64 20 55 70 | 64 61 74 65 4d 65 6e 75 |.void Up|dateMenu| |00004ee0| 73 28 76 6f 69 64 29 20 | 7b 0d 20 20 20 73 68 6f |s(void) |{. sho| |00004ef0| 72 74 20 69 3b 0d 20 20 | 20 57 69 6e 64 6f 77 50 |rt i;. | WindowP| |00004f00| 74 72 20 77 69 6e 3b 0d | 20 20 20 78 57 69 6e 64 |tr win;.| xWind| |00004f10| 6f 77 20 2a 78 77 69 6e | 3b 0d 20 20 20 77 69 6e |ow *xwin|;. win| |00004f20| 20 3d 20 46 72 6f 6e 74 | 57 69 6e 64 6f 77 28 29 | = Front|Window()| |00004f30| 3b 0d 20 20 20 69 66 20 | 28 20 77 69 6e 20 26 26 |;. if |( win &&| |00004f40| 20 28 28 57 69 6e 64 6f | 77 50 65 65 6b 29 77 69 | ((Windo|wPeek)wi| |00004f50| 6e 29 2d 3e 77 69 6e 64 | 6f 77 4b 69 6e 64 20 3c |n)->wind|owKind <| |00004f60| 20 30 20 29 20 7b 20 20 | 0d 20 20 20 20 20 20 45 | 0 ) { |. E| |00004f70| 6e 61 62 6c 65 49 74 65 | 6d 28 65 64 69 74 4d 65 |nableIte|m(editMe| |00004f80| 6e 75 2c 31 29 3b 0d 20 | 20 20 20 20 20 66 6f 72 |nu,1);. | for| |00004f90| 20 28 69 3d 33 3b 20 69 | 3c 37 3b 20 69 2b 2b 29 | (i=3; i|<7; i++)| |00004fa0| 0d 20 20 20 20 20 20 20 | 20 20 45 6e 61 62 6c 65 |. | Enable| |00004fb0| 49 74 65 6d 28 65 64 69 | 74 4d 65 6e 75 2c 69 29 |Item(edi|tMenu,i)| |00004fc0| 3b 0d 20 20 20 7d 0d 20 | 20 20 65 6c 73 65 20 7b |;. }. | else {| |00004fd0| 0d 20 20 20 20 20 20 44 | 69 73 61 62 6c 65 49 74 |. D|isableIt| |00004fe0| 65 6d 28 65 64 69 74 4d | 65 6e 75 2c 31 29 3b 0d |em(editM|enu,1);.| |00004ff0| 20 20 20 20 20 20 66 6f | 72 20 28 69 3d 33 3b 20 | fo|r (i=3; | |00005000| 69 3c 37 3b 20 69 2b 2b | 29 0d 20 20 20 20 20 20 |i<7; i++|). | |00005010| 20 20 20 44 69 73 61 62 | 6c 65 49 74 65 6d 28 65 | Disab|leItem(e| |00005020| 64 69 74 4d 65 6e 75 2c | 69 29 3b 0d 20 20 20 7d |ditMenu,|i);. }| |00005030| 0d 20 20 20 69 66 20 28 | 77 69 6e 20 26 26 20 78 |. if (|win && x| |00005040| 57 69 6e 64 6f 77 3a 3a | 57 69 6e 64 6f 77 32 58 |Window::|Window2X| |00005050| 57 69 6e 64 6f 77 28 77 | 69 6e 2c 26 78 77 69 6e |Window(w|in,&xwin| |00005060| 29 29 20 7b 0d 20 20 20 | 20 20 20 45 6e 61 62 6c |)) {. | Enabl| |00005070| 65 49 74 65 6d 28 66 69 | 6c 65 4d 65 6e 75 2c 32 |eItem(fi|leMenu,2| |00005080| 29 3b 20 20 0d 20 20 20 | 7d 0d 20 20 20 65 6c 73 |); . |}. els| |00005090| 65 20 7b 0d 20 20 20 20 | 20 20 44 69 73 61 62 6c |e {. | Disabl| |000050a0| 65 49 74 65 6d 28 66 69 | 6c 65 4d 65 6e 75 2c 32 |eItem(fi|leMenu,2| |000050b0| 29 3b 0d 20 20 20 7d 0d | 7d 0d 0d 76 6f 69 64 20 |);. }.|}..void | |000050c0| 44 6f 45 64 69 74 4d 65 | 6e 75 28 69 6e 74 20 69 |DoEditMe|nu(int i| |000050d0| 74 65 6d 4e 75 6d 29 20 | 7b 0d 7d 0d 0d 76 6f 69 |temNum) |{.}..voi| |000050e0| 64 20 44 6f 46 69 6c 65 | 4d 65 6e 75 28 69 6e 74 |d DoFile|Menu(int| |000050f0| 20 69 74 65 6d 4e 75 6d | 2c 20 69 6e 74 2a 20 64 | itemNum|, int* d| |00005100| 6f 6e 65 29 20 7b 0d 20 | 20 20 78 57 69 6e 64 6f |one) {. | xWindo| |00005110| 77 20 2a 77 69 6e 3b 0d | 20 20 20 69 66 20 28 69 |w *win;.| if (i| |00005120| 74 65 6d 4e 75 6d 20 3d | 3d 20 34 29 0d 20 20 20 |temNum =|= 4). | |00005130| 20 20 20 2a 64 6f 6e 65 | 20 3d 20 31 3b 0d 20 20 | *done| = 1;. | |00005140| 20 65 6c 73 65 20 69 66 | 20 28 69 74 65 6d 4e 75 | else if| (itemNu| |00005150| 6d 20 3d 3d 20 31 29 0d | 20 20 20 20 20 20 44 6f |m == 1).| Do| |00005160| 4e 65 77 43 6f 6d 6d 61 | 6e 64 28 29 3b 0d 20 20 |NewComma|nd();. | |00005170| 20 65 6c 73 65 20 69 66 | 20 28 69 74 65 6d 4e 75 | else if| (itemNu| |00005180| 6d 20 3d 3d 20 32 20 26 | 26 20 78 57 69 6e 64 6f |m == 2 &|& xWindo| |00005190| 77 3a 3a 57 69 6e 64 6f | 77 32 58 57 69 6e 64 6f |w::Windo|w2XWindo| |000051a0| 77 28 46 72 6f 6e 74 57 | 69 6e 64 6f 77 28 29 2c |w(FrontW|indow(),| |000051b0| 26 77 69 6e 29 29 0d 20 | 20 20 20 20 20 77 69 6e |&win)). | win| |000051c0| 2d 3e 43 6c 6f 73 65 28 | 29 3b 0d 7d 0d 0d 76 6f |->Close(|);.}..vo| |000051d0| 69 64 20 44 6f 4f 74 68 | 65 72 4d 65 6e 75 28 69 |id DoOth|erMenu(i| |000051e0| 6e 74 20 6d 65 6e 75 49 | 44 2c 20 69 6e 74 20 69 |nt menuI|D, int i| |000051f0| 74 65 6d 4e 75 6d 29 20 | 7b 0d 7d 0d 0d 0d 2f 2f |temNum) |{.}...//| |00005200| 20 41 70 70 6c 69 63 61 | 69 74 6f 6e 49 64 6c 65 | Applica|itonIdle| |00005210| 20 73 65 6e 64 73 20 74 | 68 65 20 6d 65 73 73 61 | sends t|he messa| |00005220| 67 65 20 70 6c 61 79 50 | 69 65 63 65 20 74 6f 20 |ge playP|iece to | |00005230| 74 68 65 20 66 69 72 73 | 74 20 77 69 6e 64 6f 77 |the firs|t window| |00005240| 20 6f 6e 20 74 68 65 20 | 0d 2f 2f 20 6c 69 73 74 | on the |.// list| |00005250| 20 6f 66 20 6f 70 65 6e | 20 77 69 6e 64 6f 77 73 | of open| windows| |00005260| 2e 20 20 28 54 68 61 74 | 20 77 69 6e 64 6f 77 20 |. (That| window | |00005270| 77 69 6c 6c 20 69 6e 20 | 74 75 72 6e 20 73 65 6e |will in |turn sen| |00005280| 64 20 74 68 65 20 6d 65 | 73 73 61 67 65 20 6f 6e |d the me|ssage on| |00005290| 20 0d 2f 2f 20 64 6f 77 | 6e 20 74 68 65 20 6c 69 | .// dow|n the li| |000052a0| 73 74 2c 20 73 6f 20 74 | 68 61 74 20 65 61 63 68 |st, so t|hat each| |000052b0| 20 77 69 6e 64 6f 77 20 | 77 69 6c 6c 20 68 61 76 | window |will hav| |000052c0| 65 20 61 20 63 68 61 6e | 63 65 20 74 6f 20 70 6c |e a chan|ce to pl| |000052d0| 61 79 20 6f 6e 65 0d 2f | 2f 20 70 69 65 63 65 2c |ay one./|/ piece,| |000052e0| 20 65 61 63 68 20 74 69 | 6d 65 20 41 70 70 6c 69 | each ti|me Appli| |000052f0| 63 61 74 69 6f 6e 49 64 | 6c 65 20 69 73 20 63 61 |cationId|le is ca| |00005300| 6c 6c 65 64 2e 29 0d 0d | 76 6f 69 64 20 41 70 70 |lled.)..|void App| |00005310| 6c 69 63 61 74 69 6f 6e | 49 64 6c 65 28 76 6f 69 |lication|Idle(voi| |00005320| 64 29 20 7b 0d 20 20 20 | 69 66 20 28 78 57 69 6e |d) {. |if (xWin| |00005330| 64 6f 77 4c 69 73 74 29 | 20 20 2f 2f 20 63 68 65 |dowList)| // che| |00005340| 63 6b 20 69 66 20 74 68 | 65 20 6c 69 73 74 20 69 |ck if th|e list i| |00005350| 73 20 65 6d 70 74 79 2e | 0d 20 20 20 20 20 28 28 |s empty.|. ((| |00005360| 6d 79 57 69 6e 64 6f 77 | 2a 29 78 57 69 6e 64 6f |myWindow|*)xWindo| |00005370| 77 4c 69 73 74 29 2d 3e | 70 6c 61 79 50 69 65 63 |wList)->|playPiec| |00005380| 65 28 29 3b 0d 20 20 20 | 2f 2f 20 54 68 65 20 74 |e();. |// The t| |00005390| 79 70 65 20 63 61 73 74 | 20 69 73 20 6e 65 63 65 |ype cast| is nece| |000053a0| 73 73 61 72 79 20 73 69 | 6e 63 65 20 78 57 69 6e |ssary si|nce xWin| |000053b0| 64 6f 77 4c 69 73 74 20 | 69 73 20 64 65 63 6c 61 |dowList |is decla| |000053c0| 72 65 64 20 74 6f 20 62 | 65 20 6f 66 20 74 79 70 |red to b|e of typ| |000053d0| 65 0d 20 20 20 2f 2f 20 | 78 57 69 6e 64 6f 77 2c |e. // |xWindow,| |000053e0| 20 6e 6f 74 20 6d 79 57 | 69 6e 64 6f 77 2c 20 61 | not myW|indow, a| |000053f0| 6e 64 20 6f 6e 6c 79 20 | 6d 79 57 69 6e 64 6f 77 |nd only |myWindow| |00005400| 73 20 68 61 76 65 20 61 | 20 66 75 6e 63 74 69 6f |s have a| functio| |00005410| 6e 20 70 6c 61 79 50 69 | 65 63 65 2e 0d 7d 0d 0d |n playPi|ece..}..| |00005420| 76 6f 69 64 20 43 6c 65 | 61 6e 55 70 41 70 70 6c |void Cle|anUpAppl| |00005430| 69 63 61 74 69 6f 6e 28 | 76 6f 69 64 29 20 7b 0d |ication(|void) {.| |00005440| 7d 0d 0d 0d 2f 2f 20 53 | 65 74 20 75 70 20 69 6e |}...// S|et up in| |00005450| 66 6f 72 6d 61 74 69 6f | 6e 20 61 62 6f 75 74 20 |formatio|n about | |00005460| 70 72 6f 67 72 61 6d 20 | 66 6f 72 20 74 68 65 20 |program |for the | |00005470| 41 62 6f 75 74 20 62 6f | 78 3a 0d 76 6f 69 64 20 |About bo|x:.void | |00005480| 41 62 6f 75 74 42 6f 78 | 28 76 6f 69 64 29 20 7b |AboutBox|(void) {| |00005490| 0d 20 20 20 50 61 72 61 | 6d 54 65 78 74 28 20 22 |. Para|mText( "| |000054a0| 5c 70 50 65 6e 74 6f 6d | 69 6e 6f 73 3a 20 20 41 |\pPentom|inos: A| |000054b0| 6e 20 65 6e 74 65 72 74 | 61 69 6e 6d 65 6e 74 22 |n entert|ainment"| |000054c0| 2c 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |,. | | |000054d0| 22 5c 70 44 61 76 69 64 | 20 45 63 6b 22 2c 0d 20 |"\pDavid| Eck",. | |000054e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 22 5c 70 | | "\p| |000054f0| 48 6f 62 61 72 74 20 61 | 6e 64 20 57 69 6c 6c 69 |Hobart a|nd Willi| |00005500| 61 6d 20 53 6d 69 74 68 | 20 43 6f 6c 6c 65 67 65 |am Smith| College| |00005510| 73 5c 72 47 65 6e 65 76 | 61 2c 20 4e 59 20 20 31 |s\rGenev|a, NY 1| |00005520| 34 34 35 36 5c 72 45 2d | 6d 61 69 6c 3a 20 65 63 |4456\rE-|mail: ec| |00005530| 6b 40 68 77 73 2e 62 69 | 74 6e 65 74 22 2c 0d 20 |k@hws.bi|tnet",. | |00005540| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 22 5c 70 | | "\p| |00005550| 54 68 69 73 20 70 72 6f | 67 72 61 6d 20 74 72 69 |This pro|gram tri| |00005560| 65 73 20 74 6f 20 70 6c | 61 63 65 20 74 68 65 20 |es to pl|ace the | |00005570| 31 32 20 70 65 6e 74 6f | 6d 69 6e 6f 73 20 28 74 |12 pento|minos (t| |00005580| 69 6c 65 73 20 74 68 61 | 74 20 63 61 6e 20 62 65 |iles tha|t can be| |00005590| 20 6d 61 64 65 20 77 69 | 74 68 20 35 20 73 71 75 | made wi|th 5 squ| |000055a0| 61 72 65 73 29 20 6f 6e | 20 61 6e 20 38 2d 62 79 |ares) on| an 8-by| |000055b0| 2d 38 20 62 6f 61 72 64 | 2e 20 20 45 61 63 68 20 |-8 board|. Each | |000055c0| 74 69 6c 65 20 69 73 20 | 64 69 73 70 6c 61 79 65 |tile is |displaye| |000055d0| 64 20 77 69 74 68 20 61 | 20 64 69 66 66 65 72 65 |d with a| differe| |000055e0| 6e 74 20 6c 65 74 74 65 | 72 2e 22 29 3b 0d 20 20 |nt lette|r.");. | |000055f0| 20 41 6c 65 72 74 28 31 | 32 38 2c 30 4c 29 3b 0d | Alert(1|28,0L);.| |00005600| 7d 0d 0d 0d 76 6f 69 64 | 20 44 6f 4e 65 77 43 6f |}...void| DoNewCo| |00005610| 6d 6d 61 6e 64 28 76 6f | 69 64 29 20 7b 0d 20 20 |mmand(vo|id) {. | |00005620| 20 6d 79 57 69 6e 64 6f | 77 20 2a 70 65 6e 74 57 | myWindo|w *pentW| |00005630| 69 6e 3b 0d 20 20 20 57 | 69 6e 64 6f 77 43 74 2b |in;. W|indowCt+| |00005640| 2b 3b 20 20 2f 2f 20 63 | 6f 75 6e 74 20 74 68 65 |+; // c|ount the| |00005650| 20 77 69 6e 64 6f 77 73 | 20 74 68 61 74 20 68 61 | windows| that ha| |00005660| 76 65 20 62 65 65 6e 20 | 6f 70 65 6e 65 64 2f 0d |ve been |opened/.| |00005670| 20 20 20 70 65 6e 74 57 | 69 6e 20 3d 20 6e 65 77 | pentW|in = new| |00005680| 20 6d 79 57 69 6e 64 6f | 77 3b 0d 20 20 20 70 65 | myWindo|w;. pe| |00005690| 6e 74 57 69 6e 2d 3e 4f | 70 65 6e 28 22 5c 70 43 |ntWin->O|pen("\pC| |000056a0| 6c 69 63 6b 20 34 20 53 | 71 75 61 72 65 73 22 29 |lick 4 S|quares")| |000056b0| 3b 20 20 2f 2f 20 69 6e | 69 74 69 61 6c 20 74 69 |; // in|itial ti| |000056c0| 74 6c 65 20 66 6f 72 20 | 77 69 6e 64 6f 77 20 74 |tle for |window t| |000056d0| 65 6c 6c 73 20 74 68 65 | 0d 20 20 20 20 20 20 20 |ells the|. | |000056e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |000056f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | | |00005700| 20 2f 2f 20 75 73 65 72 | 20 77 68 61 74 20 74 6f | // user| what to| |00005710| 20 64 6f 2e 0d 7d 0d 0d | 00 00 00 00 00 00 00 00 | do..}..|........| |00005720| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005730| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005740| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005750| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005760| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005770| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00005780| 00 00 01 00 00 00 02 32 | 00 00 01 32 00 00 00 32 |.......2|...2...2| |00005790| 77 3a 3a 57 69 6e 64 6f | 77 32 58 57 69 6e 64 6f |w::Windo|w2XWindo| |000057a0| 77 28 28 57 69 6e 64 6f | 77 50 74 72 29 67 45 76 |w((Windo|wPtr)gEv| |000057b0| 0c 70 65 6e 74 6f 6d 69 | 6e 6f 73 2e 63 b7 02 00 |.pentomi|nos.c...| |000057c0| 00 00 50 61 72 74 53 49 | 54 78 00 00 00 00 00 00 |..PartSI|Tx......| |000057d0| 00 00 50 61 72 74 53 49 | 54 78 00 00 00 00 00 00 |..PartSI|Tx......| |000057e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |000057f0| 00 00 a9 80 1b 71 00 00 | 00 00 00 00 02 64 20 20 |.....q..|.....d | |00005800| 20 7d 0d 20 20 20 20 20 | 20 20 20 20 20 63 61 73 | }. | cas| |00005810| 65 20 61 63 74 69 76 61 | 74 65 45 76 74 3a 20 7b |e activa|teEvt: {| |00005820| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 20 69 66 |. | if| |00005830| 20 28 78 57 69 6e 64 6f | 77 3a 3a 57 69 6e 64 6f | (xWindo|w::Windo| |00005840| 77 32 58 57 69 6e 64 6f | 77 28 28 57 69 6e 64 6f |w2XWindo|w((Windo| |00005850| 77 50 74 72 29 67 45 76 | 65 6e 74 2e 6d 65 73 73 |wPtr)gEv|ent.mess| |00005860| 61 67 65 2c 26 77 69 6e | 29 29 0d 20 20 20 20 20 |age,&win|)). | |00005870| 20 20 20 20 20 20 20 20 | 20 20 20 77 69 6e 2d 3e | | win->| |00005880| 00 00 01 2e 00 0c 00 00 | 54 00 00 00 54 08 09 41 |........|T...T..A| |00005890| 62 6f 75 74 42 6f 78 00 | 00 00 52 8d 00 00 52 9c |boutBox.|..R...R.| |000058a0| 0f 41 70 70 6c 69 63 61 | 74 69 6f 6e 49 64 6c 65 |.Applica|tionIdle| |000058b0| 00 00 27 13 00 00 27 21 | 0f 63 6c 61 73 73 20 6d |..'...'!|.class m| |000058c0| 79 57 69 6e 64 6f 77 00 | 00 00 55 89 00 00 55 95 |yWindow.|..U...U.| |000058d0| 0d 44 6f 4e 65 77 43 6f | 6d 6d 61 6e 64 00 00 00 |.DoNewCo|mmand...| |000058e0| 25 50 00 00 25 5a 0b 65 | 72 61 73 65 50 69 65 63 |%P..%Z.e|rasePiec| |000058f0| 65 00 00 00 43 bc 00 00 | 43 d4 19 6d 79 57 69 6e |e...C...|C..myWin| |00005900| 64 6f 77 3a 3a 64 6f 43 | 6f 6e 74 65 6e 74 43 6c |dow::doC|ontentCl| |00005910| 69 63 6b 00 00 00 42 f4 | 00 00 43 03 0f 6d 79 57 |ick...B.|..C..myW| |00005920| 69 6e 64 6f 77 3a 3a 64 | 6f 4b 65 79 00 00 49 44 |indow::d|oKey..ID| |00005930| 00 00 49 56 13 6d 79 57 | 69 6e 64 6f 77 3a 3a 64 |..IV.myW|indow::d| |00005940| 6f 52 65 64 72 61 77 00 | 00 00 40 6a 00 00 40 7e |oRedraw.|..@j..@~| |00005950| 15 6d 79 57 69 6e 64 6f | 77 3a 3a 4f 70 65 6e 49 |.myWindo|w::OpenI| |00005960| 6e 52 65 63 74 00 00 00 | 31 b1 00 00 31 c4 13 6d |nRect...|1...1..m| |00005970| 79 57 69 6e 64 6f 77 3a | 3a 70 6c 61 79 50 69 65 |yWindow:|:playPie| |00005980| 63 65 00 00 3c 22 00 00 | 3c 37 15 6d 79 57 69 6e |ce..<"..|<7.myWin| |00005990| 64 6f 77 3a 3a 53 65 74 | 44 65 66 61 75 6c 74 73 |dow::Set|Defaults| |000059a0| 00 00 21 27 00 00 21 2f | 09 70 75 74 50 69 65 63 |..!'..!/|.putPiec| |000059b0| 65 00 00 00 01 00 00 00 | 02 32 00 00 01 32 00 00 |e.......|.2...2..| |000059c0| 00 32 00 68 ac 9c 05 26 | 00 00 00 1c 00 32 00 00 |.2.h...&|.....2..| |000059d0| 4d 50 53 52 00 00 00 0a | 03 ef ff ff 00 00 00 00 |MPSR....|........| |000059e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |000059f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| +--------+-------------------------+-------------------------+--------+--------+